我遇到了一个问题,其中我在Flask应用程序中发布帖子并收到Flask页面响应:错误请求浏览器或代理发送了该服务器无法理解的请求。
有关一些有用的细节...
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);
未能发布并给出了提及的“错误请求”
编辑json字符串为
String testjsonstr = "["+jsonList.get(0).toString()+","+jsonList.get(1).toString()+"]";
结果发布成功。我已经测试了这个以及jsonList工作中2个项目的任意组合。当我尝试将第三项添加到json列表时,出现错误。有任何想法吗?
最佳答案
知道了,json数据utf-8中有不间断空格,列为C2A0。