Flask REST POST 请求失败 "Bad Request" 基于 json 的长度

Flask REST POST request failing "Bad Request" based on length of json

我 运行 遇到一个问题,我正在向 Flask 应用程序发送 posts 并收到 Flask 页面响应:Bad Request 浏览器或代理发送了一个请求,该服务器可以不明白。

一些有用的细节...

    String testjsonstr = "["+jsonList.get(0).toString()+","+jsonList.get(1).toString()+","+jsonList.get(2).toString()+"]";
    StringEntity se = new StringEntity(testjsonstr);
    httpPost.setEntity(se);
    httpPost.setHeader("Accept", "application/json");
    httpPost.setHeader("Content-type", "application/json");
    httpPost.setHeader("Accept-Charset", "utf-8");
    HttpResponse httpResponse = httpclient.execute(httpPost);

未能达到 post 并给出提到的 'bad request'

将 json 字符串编辑为

 String testjsonstr = "["+jsonList.get(0).toString()+","+jsonList.get(1).toString()+"]";

结果成功 post。我已经测试了这个以及 jsonList 工作中的 2 个项目的任意组合。当我尝试将第三项添加到 json 列表时,出现错误。有什么想法吗?

知道 json 数据中有不间断空格 utf-8 被列为 C2A0。