Growth 50%
上面是我的curl和Java代码。
我已经设置了通知类型,但在运行时,仍然有400个错误提示:
// curl -v -S -u root:abc123456 -F'notification={"applicationId":"229396","schemaId":"229506","topicId":"98315","type":"USER"};type=application/json' "http://wy.com/" | python -mjson.tool
CloseableHttpClient client = HttpClients.createDefault();
HttpPost post = new HttpPost(url);
MultipartEntity reqEntity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE);
StringBody comment = new StringBody(param,ContentType.APPLICATION_JSON);
reqEntity.addPart("notification", comment);
post.setEntity(reqEntity);
post.addHeader("Authorization", getHeader(authString));
是否有人可以帮助我了解问题所在?
答案 0 :(得分:0)
问题已经解决
StringBody comment = new StringBody(param,ContentType.APPLICATION_JSON);
更改为以下
StringBody comment = new StringBody(param,ContentType.create("application/json"));
并且,HttpMultipartMode.BROWSER_COMPATIBLE 除去
测试成功通过