当我在没有参数的情况下发布帖子时我正在连接到休息api我得到一个返回但是一旦我尝试添加参数
JSONObject obj = new JSONObject();
obj.put("ID", "44");
StringEntity se = new StringEntity(obj.toString());
post.setEntity(se);
post.setHeader("Accept", "application/json");
post.setHeader("Content-type", "application/json");
HttpResponse response = client.execute(post);
过滤数据我得到以下回复
{ “错误”: “ERROR_CORE”, “ERROR_DESCRIPTION”:“TASKS_ERROR_EXCEPTION_#256; 方法ctaskitem :: getlist()的Param#0(arOrder)应该是 输入\ u0022array \ u0022,但给出别的东西。 256 / TE / WRONG_ARGUMENTS \ u003Cbr \ u003E“}
如何将参数作为数组发送?
答案 0 :(得分:1)
请尝试:
List<String> orders = new ArrayList<>();
orders.add("44");
JSONObject obj = new JSONObject();
obj.put("arOrder", orders);
StringEntity se = new StringEntity(obj.toString());
post.setEntity(se);
post.setHeader("Accept", "application/json");
post.setHeader("Content-type", "application/json");
HttpResponse response = client.execute(post);
阅读完文档后,请尝试发送以下JSON:
[
{ "ID" : "desc" },
{ "ID" : ["44"] }, // or [44] plain int
[ "ID", "TITLE"]
]