你如何做一个HTTP PUT?我正在使用的类似乎认为它正在执行 PUT,但端点将其视为我执行了 GET。我做错什么了吗?
URL url = new URL("https://...");
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setDoOutput(true);
conn.setRequestMethod("PUT");
OutputStreamWriter writer = new OutputStreamWriter(conn.getOutputStream());
writer.write(xmlString);
writer.close();
System.out.println(conn.getRequestMethod());
String response = readInputStream(conn.getInputStream());
System.out.println(response);
哪个正在打印:
PUT
<same content as doing a GET>
如果这个库可以工作,我宁愿不包含另一个库......