400 HTTPClient请求的响应代码错误

时间:2019-10-29 11:20:41

标签: json httpurlconnection patch http-status-code-400

我正在使用Http客户端请求,在这里我得到400的响应代码。使用JSON正文

由于错误请求而收到HTTP错误400。与邮递员合作很好。

HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setRequestProperty("Content-Type", "application/json");
conn.setRequestProperty("Accept", "application/json");
conn.setRequestProperty("Content-Type", "text/html; charset=utf-8");
                    conn.setRequestProperty("Accept","application/atom+xml");
conn.setDoOutput(true);
conn.setRequestProperty("X-HTTP-Method-Override", "PATCH");
conn.setRequestMethod("POST");
conn.setRequestProperty("indexName", "indx");
conn.setRequestProperty("indexValue", "0004046508");
OutputStreamWriter out = new OutputStreamWriter(conn.getOutputStream());
out.write(jsonInput);
TraceInfo.trace(ITraceInfo.TRACE_LEVEL_DEBUG,"URL " + url, mySession);
out.close();

0 个答案:

没有答案