代码如下,但是返回的信息是400错误

public class request {

    public static void main(String[] args) {


        String url = "https://api.leancloud.cn/1.1/rtm/messages";
        JSONObject param3 = new JSONObject();
        String[] arg= {"yezibao", "test8"};
        JSONObject paramSend = new JSONObject();

        JSONObject msg = new JSONObject();
        msg.put("_lctype", -1);
        msg.put("_lctext", "文本消息");

        paramSend.put("message", msg.toString());
        paramSend.put("from_peer", "test9");
        paramSend.put("to_peers", arg);
        paramSend.put("conv_id", "591bc5da2f301e00588ca7e2");
        paramSend.put("push_data", "系统对话测试推送");
        String result = doPost(url, paramSend);

    }

    public static String doPost(String url,JSONObject json){
        DefaultHttpClient client = new DefaultHttpClient();
        HttpPost post = new HttpPost(url);
        String result = null;
        try {
            StringEntity s = new StringEntity(json.toString(), "UTF-8");
            s.setContentEncoding("UTF-8");
            s.setContentType("application/json");
            post.setHeader("Content-Type","application/json");
            post.setHeader("X-LC-Id","****");
            post.setHeader("X-LC-Key","****");
            post.setEntity(s);
            HttpResponse res = client.execute(post);
            if(res.getStatusLine().getStatusCode() == HttpStatus.SC_OK){
                HttpEntity entity = res.getEntity();
                result = EntityUtils.toString(res.getEntity());
            }
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
        return result;
    }
}

返回错误信息:

2017 五月 17 13:46:06 Receiving response: HTTP/1.1 400 Bad Request org.apache.http.impl.conn.DefaultClientConnection
2017 五月 17 13:46:06 << HTTP/1.1 400 Bad Request org.apache.http.headers
2017 五月 17 13:46:06 << Server: Tengine org.apache.http.headers
2017 五月 17 13:46:06 << Date: Wed, 17 May 2017 06:47:44 GMT org.apache.http.headers
2017 五月 17 13:46:06 << Content-Type: application/json;charset=utf-8 org.apache.http.headers
2017 五月 17 13:46:06 << Content-Length: 76 org.apache.http.headers

新的发现:
我把to_peers改成这个怎样子:
paramSend.put("to_peers", "[\"test8\", \"yezibao\" ]");
字符串形式的数组?说好的数组呢
不返回400错误了,而是返回201,但是我查看消息记录又什么都没有

2017 五月 17 15:08:14 Receiving response: HTTP/1.1 201 Created org.apache.http.impl.conn.DefaultClientConnection
2017 五月 17 15:08:14 << HTTP/1.1 201 Created org.apache.http.headers
2017 五月 17 15:08:14 << Server: Tengine org.apache.http.headers
2017 五月 17 15:08:14 << Date: Wed, 17 May 2017 08:09:53 GMT org.apache.http.headers
2017 五月 17 15:08:14 << Content-Type: application/json;charset=utf-8 org.apache.http.headers

请问这是什么原因呢? 实在是没找到

您好,建议捕捉一下全部的 curl 请求,然后和文档的 curl 请求对比一下,看看有没有什么问题。

第二天后变成了201 第三天后就正常200了.....我也不知道什么情况 现在可以了