如何将列表发布到Advanced Rest Client

时间:2015-04-15 13:42:37

标签: java list rest service client

我的服务代码:

public RestResponse deleteEvents(@RequestBody List<RecordDto> delete, @RequestBody List<RecordDto> update)

这是我的RecordDto参数:

private long uid;

private int type;

private String identification;

private String target;

private String reason;

private boolean edited;

private boolean deleted;

我使用application/json作为“内容类型” 我只是想获得200 OK消息。所以价值观现在并不重要。 我应该在Advanced Rest Client(谷歌Chrome应用程序)上写什么原始文件?

我编辑了我的代码,如

public RestResponse updating(@RequestBody Update Update)

这里是更新:

private List<RecordDto> delete;
private List<RecordDto> update;

RecordDto:

private long uid;
private String ip;
private String cidr;
private String accesRule;
private boolean enabled;
private String createDate;

我正在尝试使用Rest Client:

 {"delete":["uid":"", "ip":"" "cidr":"", "accesRule":"", "enabled":"", "createDate":""], 
  "update":["uid":"", "ip":"" "cidr":"", "accesRule":"", "enabled":"", "createDate":""]}

我为其他休息服务使用空值,它们工作正常。但我不知道为什么这个不起作用。

2 个答案:

答案 0 :(得分:3)

我找到答案:)这里是:

{
    "delete": [
        {
            "uid": "",
            "ip": "",
            "cidr": "",
            "accesRule": "",
            "enabled": "",
            "createDate": ""
        }
    ],
    "update": [
        {
            "uid": "",
            "ip": "",
            "cidr": "",
            "accesRule": "",
            "enabled": "",
            "createDate": ""
        }
    ]
}

答案 1 :(得分:0)

如果我理解正确,您想知道如何从测试客户端测试它以及数据必须是什么样的。

这是你需要发布的一系列对象

[
    {
        "uid": 243,
        "type": 1,
        "identification": "some string",
        "target": "more strings",
        "reason": "reason",
        "edited": false,
        "deleted" false
    },
    {
        "uid": 243,
        "type": 1,
        "identification": "some string",
        "target": "more strings",
        "reason": "reason",
        "edited": false,
        "deleted" false
    }
]