将参数作为数组发送到java中带有httpost的Rest Api

将参数作为数组发送到java中带有httpost的Rest Api,java,rest,Java,Rest,当我在没有参数的情况下发布文章时,我连接到了一个RESTAPI,我得到了一个返回,但当我尝试添加参数时 JSONObject obj = new JSONObject(); obj.put("ID", "44"); StringEntity se = new StringEntity(obj.toString()); post.setEntity(se); post.setHeader("Accept", "application/json"); post

当我在没有参数的情况下发布文章时,我连接到了一个RESTAPI,我得到了一个返回,但当我尝试添加参数时

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”:“error_CORE”,“error_description”:“TASKS_error_EXCEPTION_35;256; 方法ctaskitem::getlist()的参数0(arOrder)应为 键入\u0022array\u0022,但给定其他内容。; 256/TE/错误的参数\u003Cbr\u003E“}

如何将参数作为数组发送?

请尝试:

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);

现在没有得到错误,但是数据没有被过滤这是我关于api的信息,
JSONObject的包是什么
?你需要发送的是:
[{“ID”:[“44”]}]
。你能自己构造这样的查询吗?org.json.simple.JSONObjectI可以尝试,但不知道我是否会成功。
[
  { "ID" : "desc" }, 
  { "ID" : ["44"] }, // or [44] plain int
  [ "ID", "TITLE"]
]