0
public static boolean deleteSubscribe(String subscription_id, String authToken){
    HttpClient httpClient = new DefaultHttpClient();
    HttpPost httpPost = new HttpPost("https://gdata.youtube.com/feeds/api/users/default/subscriptions/"+subscription_id+"?v=2");
    httpPost.setHeader("DELETE", "/feeds/api/users/default/subscriptions/"+subscription_id+" HTTP/1.1"); 
    httpPost.setHeader("Host", "gdata.youtube.com"); 
    httpPost.setHeader("Authorization", "Bearer "+authToken);
    httpPost.setHeader("GData-Version", "2");
    httpPost.setHeader("X-GData-Key", "key="+DeveloperKey.DEVELOPER_KEY);
    HttpResponse httpResponse = null;
    httpPost.setHeader("Content-type","application/atom+xml");

    try {

        httpResponse = httpClient.execute(httpPost);
        BufferedReader reader = new BufferedReader(new InputStreamReader(httpResponse.getEntity().getContent(), "UTF-8"));
        String json = reader.readLine();
        System.out.println("remove:" + json);

    } catch (ClientProtocolException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }

    return (httpResponse.getStatusLine().getStatusCode() == HttpStatus.SC_CREATED);
}

I am using this code to delete subscribe in Youtube API. I can add subscribe with succesfully but i got an error when delete function:

http://schemas.google.com/g/2005'>GDatainvalidRequestUriInvalid request URI

Original link to docs.

Anyone can help please?

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
ghiba
  • 1
  • 1

1 Answers1

1

Try to urlencode your developer key, authtoken and subscription_id.

agamov
  • 4,407
  • 1
  • 27
  • 31
  • I found my solution: http://stackoverflow.com/questions/1051004/how-to-send-put-delete-http-request-in-httpurlconnection-looks-like-not-workin Thanks all – ghiba Mar 03 '13 at 15:04