0

I want to perform delete subscription of youtube api V3 in my application. But I am not able to get it. Here my code is

HttpDelete httDelete = new HttpDelete("https://www.googleapis.com/youtube/v3/subscriptions");
httDelete.setHeader("Content-Type", "application/json");
httDelete.setHeader("Authorization",MY_ACCESS_TOKEN);
httDelete.setHeader("id",channelId");
HttpClient httpclient = new DefaultHttpClient();
HttpResponse response = httpclient.execute(httDelete);
String responseString = StreamUtils.convertToString(response.getEntity().getContent());

Here is my response

{
 "error": {
  "errors": [
  {
   "domain": "global",
  "reason": "required",
    "message": "Required parameter: id",
  "locationType": "parameter",
  "location": "id"
 }
   ],
  "code": 400,
"message": "Required parameter: id"
  }

Please give me any suggestions.I am waiting for your quick response.

4

1 回答 1

0

您需要在请求的正文中指定“id”,而不是在标头上。如在

删除 https://www.googleapis.com/youtube/v3/subscriptions?id=id&key= {YOUR_API_KEY}

但我建议您使用YouTube API Java 客户端库以便于使用。

YouTube Direct Lite for Android项目中有一个 Android 工作示例。

于 2013-11-15T18:25:21.927 回答