Question

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.

Was it helpful?

Solution

You need to specify the "id" in the body of the request, not on the header. as in

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

but I suggest you to use YouTube API Java client library for easy of use.

There is an Android working example on YouTube Direct Lite for Android project.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top