Java休息:400。请求形成不佳:URL包含 - > API/组件(848569)/properties(利益相关者|应用程序管理器')
我的URL是:
https://te.avolutionsoftware.com/api/Components(848569)/Properties('Stakeholder|Application Manager')
当我使用时,
allowMethods("PATCH");
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
String auth = bearerToken;
//byte[] encodedAuth = Base64.getEncoder().encode(auth.getBytes(StandardCharsets.UTF_8));
String authHeaderValue = "Bearer " + new String(auth);
conn.setRequestProperty("Authorization", authHeaderValue);
//conn.setRequestProperty("X-HTTP-Method-Override", "PATCH");
conn.setRequestMethod(method);
conn.setRequestProperty("Content-Type", "application/json");
String input = data;//"{\"qty\":100,\"name\":\"iPad 4\"}";
conn.setDoOutput(true);
conn.setRequestProperty("Content-Length", String.valueOf(input.length()));
OutputStream os = conn.getOutputStream();
os.write(input.getBytes());
os.flush();
请始终给出
<HTML><HEAD><TITLE>Bad Request</TITLE><META HTTP-EQUIV="Content-Type" Content="text/html; charset=us-ascii"></HEAD><BODY><h2>Bad Request</h2><hr><p>HTTP Error 400. The request is badly formed.</p>
我的JSON主体:
{"Value": "Update Test"}
相同的Java方法在带有不同URL的“发布”方面正常工作。
URL在Postman中与补丁和相同的JSON身体字符串正常工作。
任何建议在这里可能出现什么
My URL is:
https://te.avolutionsoftware.com/api/Components(848569)/Properties('Stakeholder|Application Manager')
When i am using
allowMethods("PATCH");
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
String auth = bearerToken;
//byte[] encodedAuth = Base64.getEncoder().encode(auth.getBytes(StandardCharsets.UTF_8));
String authHeaderValue = "Bearer " + new String(auth);
conn.setRequestProperty("Authorization", authHeaderValue);
//conn.setRequestProperty("X-HTTP-Method-Override", "PATCH");
conn.setRequestMethod(method);
conn.setRequestProperty("Content-Type", "application/json");
String input = data;//"{\"qty\":100,\"name\":\"iPad 4\"}";
conn.setDoOutput(true);
conn.setRequestProperty("Content-Length", String.valueOf(input.length()));
OutputStream os = conn.getOutputStream();
os.write(input.getBytes());
os.flush();
Always give
<HTML><HEAD><TITLE>Bad Request</TITLE><META HTTP-EQUIV="Content-Type" Content="text/html; charset=us-ascii"></HEAD><BODY><h2>Bad Request</h2><hr><p>HTTP Error 400. The request is badly formed.</p>
My JSON body:
{"Value": "Update Test"}
Same java method working fine for "POST" with different URL.
URL working fine in Postman with Patch and same Json Body String.
Any suggestion what could be issue here
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论