删除订阅在Youtube API V3中不起作用

时间:2013-11-15 12:14:38

标签: java android youtube youtube-api youtube-data-api

我想在我的应用程序中执行youtube api V3的删除订阅。但我无法得到它。我的代码是

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());

以下是我的回复

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

请给我任何建议。我在等你的快速反应。

1 个答案:

答案 0 :(得分:0)

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

  

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

但我建议您使用YouTube API Java client library以便于使用。

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