我想在我的应用程序中执行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"
}
请给我任何建议。我在等你的快速反应。
答案 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工作示例。