我正在玩 instagram api 端点。
他们的通话样本是:
curl -X DELETE https://api.instagram.com/v1/media/{media-id}/likes?access_token=ACCESS-TOKEN
我正在尝试从我的 android 应用程序中拨打电话,如下所示:
URL url = new URL(myBuiltUrl);
HttpsURLConnection httpsURLConnection = (HttpsURLConnection) url.openConnection();
httpsURLConnection.setRequestMethod("DELETE");
httpsURLConnection.setDoInput(true);
httpsURLConnection.setDoOutput(false);
OutputStreamWriter outputStreamWriter = new OutputStreamWriter(httpsURLConnection.getOutputStream());
outputStreamWriter.write("access_token=" + token);
outputStreamWriter.flush();
String response = streamToString(httpsURLConnection.getInputStream());
运行此代码时出现的错误是:
java.net.ProtocolException: method does not support a request body: DELETE
如何修复我的代码以正常工作?