Google Product Forums

Google reader api mark as read return 411 error

honeytidy Jun 30, 2012 5:25 AM
Posted in group: Google Mobile Help Forum

Categories: Android Devices : Android Applications :

 am doing some development about google reader on android platform.

Using google reader api, I can successfully get RSS list. But when I want to mark the RSS item as read, I got "411 Length required" error. This is my code:

HttpClient httpclient = new DefaultHttpClient();
   
HttpPost httppost = new HttpPost(
           
"http://www.google.com/reader/api/0/edit-tag");
    httppost
.addHeader("Authorization", auth);

   
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
    nameValuePairs
.add(new BasicNameValuePair("i", itemId));
    nameValuePairs
.add(new BasicNameValuePair("a",
           
"user/-/state/com.google/read"));
    nameValuePairs
.add(new BasicNameValuePair("async", "true"));
    nameValuePairs
.add(new BasicNameValuePair("T", token));
    nameValuePairs
.add(new BasicNameValuePair("s", feedUrl));
   
try {
        httppost
.setEntity(new UrlEncodedFormEntity(nameValuePairs));
       
HttpResponse response = httpclient.execute(httppost);
       
Toast.makeText(getApplicationContext(),
               
EntityUtils.toString(response.getEntity()),
               
Toast.LENGTH_LONG).show();
   
} catch (UnsupportedEncodingException e) {
       
// TODO Auto-generated catch block
        e
.printStackTrace();
   
} catch (ClientProtocolException e) {
       
// TODO Auto-generated catch block
        e
.printStackTrace();
   
} catch (IOException e) {
       
// TODO Auto-generated catch block
        e
.printStackTrace();
   
}