1

我正在玩 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

如何修复我的代码以正常工作?

4

1 回答 1

1

试着把你的 放在你的access_tokenURL,就像你用你的curl命令做的那样,然后摆脱这些outputStreamWriter东西。

于 2013-09-12T12:42:58.877 回答