400 Bad request with "mark as" (using android)

518 views
Skip to first unread message

Quint

unread,
Sep 10, 2011, 7:14:51 AM9/10/11
to Friends of the Unofficial Google Reader API
Hello,

I'm trying to use the Google Reader API for my android app and i'm
having trouble marking items as read. I'm getting 400 bad request.

Other things do work: Logging in, Getting a token, getting
subscriptions.items etc.

I'm using apache HttpClient 4. I have almost the same thing working as
a standard java application only that one uses HttpClient 3 so i had
to change it i little bit for android. But since that is working i
know a have all the parameters and headers correct.

One thing that is different from the working java version is the way
the parameters are passed in the request. In the android version it's
like this:
public String post(String pUrl, List<Parameter> pParams, boolean
pUseCookies) throws GoogleReaderException {

ArrayList<NameValuePair> postParameters =
(ArrayList<NameValuePair>) (toNameValuePairArray(pParams));

HttpPost postRequest = new HttpPost(pUrl);

try {
postRequest.setEntity(new UrlEncodedFormEntity(postParameters,
HTTP.UTF_8));
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}

return execute(postRequest, pUseCookies);
}



Here are some details of the request and response from the android
eclipse debugger:

uri :

https://www.google.com/reader/api/0/edit-tag

postparameters(before passed to UrlEncodedFormEntity()):

[s=feed%2Fhttp%3A%2F%2Fwww.androidworld.nl%2Ffeed%2F, i=tag
%3Agoogle.com%2C2005%3Areader%2Fitem%2F6ef6e1f6dc7771f9, T=//
vwbWgfeJ5Sc03YiQ-1D3Pw, async=true, pos=0, a=user/**********/state/
com.google/read]

headers:

[Authorization: GoogleLogin
auth=DQAAAMUAAAAIpsBx9lbuZgs9yVNX4LOiKyRCj7l6KOvuq_M8-AEoFf-
U2uqGuzSqsOU943W3bgYMalT1yZi0sQoKIwllp-
irESlqQI6jPouMhE6xn4Ut-9SYpujebFn_ICcJs1oN2dDqE1BO_Bym4jK1hKADHKebtV_k-
Dk-
UKvoCIFueOA_w_ZvDSrBcgHkIwIEpTNMYNzSYBfeytqYoyinHL75x4P8K9k9nU9mEXb0dbJVMutpuakIvQwUxBwedWTsv4iR5Q3tiRAO6iUmGPu6BnZJZ80R]

This kind of post works for login but somehow doesn't work now.

What is wrong?

Let me know if i need to post more detailed info (and what)

Thanks!


oliver....@googlemail.com

unread,
Sep 10, 2011, 8:11:23 AM9/10/11
to Friends of the Unofficial Google Reader API
One possible 400 bad request error:

Check if your used token is still valid. Google Reader sets the
response header "X-Reader-Google-Bad-Token" to "true" when it is
invalid.

Quint

unread,
Sep 10, 2011, 8:19:10 AM9/10/11
to Friends of the Unofficial Google Reader API
Hi,

The response header does not contain "X-Reader-Google-Bad-Token" so i
don't thing thats it..



On 10 sep, 14:11, "oliver.fuern...@googlemail.com"

oliver....@googlemail.com

unread,
Sep 10, 2011, 8:33:06 AM9/10/11
to Friends of the Unofficial Google Reader API
Sorry, but you really checked the response headers and not your
request headers as shown in your first post?

Do you see the other google reader specific response headers like:
X-Reader-Google-Version
X-Reader-User
...

This is a example when i post it:
async=true&i=tag%3Agoogle.com%2C2005%3Areader%2Fitem
%2F12169a891a3530a6&s=feed%2Fhttp%3A%2F%2Ffeeds.ismashphone.com
%2Ftypepad%2F1209935315s4903%2Fismasher&a=user%2F-%2Fstate%2Fcom.google
%2Fread&T=....

Quint

unread,
Sep 10, 2011, 10:38:14 AM9/10/11
to Friends of the Unofficial Google Reader API
This is the "header collection" in the response object:

[Content-Type: text/html; charset=UTF-8, X-Reader-Google-Version:
546-000, X-Reader-User: 11196327406850766973, Set-Cookie: GRLD=en:
11196327406850766973;Path=/reader/;HttpOnly, Date: Sat, 10 Sep 2011
14:35:16 GMT, Expires: Sat, 10 Sep 2011 14:35:16 GMT, Cache-Control:
private, max-age=0, X-Content-Type-Options: nosniff, X-Frame-Options:
SAMEORIGIN, X-XSS-Protection: 1; mode=block, Content-Length: 90,
Server: GSE]



On 10 sep, 14:33, "oliver.fuern...@googlemail.com"

Quint

unread,
Jul 13, 2012, 11:48:47 AM7/13/12
to foug...@googlegroups.com
Hello everybody,

I knows this is an old message but i'm still having this same issue.
I keep getting 400 back when a try to mark items.
I'm using Apache HttpClient on Android now but i also tried HttpUrlConnection both fail.

I have made a TCP dump on a running Android emulator and used Wireshark to analyze the packet.
I used HTTP in stead of HTTPS to be able so view the details.

I don't see what's wrong with my request.

Below are the details for the request and result.

Does anybody see what thew problem could be?

(If necessary i could post mote details from Wireshark but i thought the rest was too "low-level".)

One thing i do notice is that the edit token (T parameter) eventually get's urlencoded. But this is just how HttpClient does this i suppose:

T=%2F%2Ftan-6fN_6O_DC_KKj1Ew8Q

Could this be a problem?

These are the details:

Request:

POST /reader/api/0/edit-tag?ck=1342192642890&client=greader-unofficial HTTP/1.1
Authorization: GoogleLogin auth=DQAAAMwAAACTRsOcJlNAIvjEQRwccviNxbzvkO1-AyeL9ynWd-jmKXfBpMudrPtQECeTc_Z2DFtyzx8AHRZ8lHvXw64Eo-K18wcHsTfvSQuSmDjAX5qnHFzRcgsTuZcm5Ypgv3RGUSnvJ3hYo8kizGAySTKmTfVBKqwtWvQA3NNjCZJTsq6H3ARTR08R_W0nsapFWkNwFl5PAOPs95l6Ff_xk-cbi2Frb83nlH0EcZCyhtyaQe3OF9E7ZYpK8beAP6tH8xbhRGm-1j1hoTnEQQE-xgPwdkVi
Content-Length: 251
Content-Type: application/x-www-form-urlencoded
Host: www.google.com
Connection: Keep-Alive
User-Agent: Apache-HttpClient/UNAVAILABLE (java 1.4)
Cookie: GRLD=en:11196327406850766973
Cookie2: $Version=1
Accept-Encoding: gzip

Line-based text data: application/x-www-form-urlencoded:

s=feed%252Fhttp%253A%252F%252Ffeeds.gawker.com%252Fgizmodo%252Ffull&i=tag%253Agoogle.com%252C2005%253Areader%252Fitem%252Fa0ca8b45f85d17c9&T=%2F%2Ftan-6fN_6O_DC_KKj1Ew8Q&async=true&pos=0&a=user%2F******%40gmail.com%2Fstate%2Fcom.google%2Fstarred

Result:

HTTP/1.1 400 Bad Request
Content-Type: text/html; charset=UTF-8
X-Reader-Google-Version: 553-000
X-Reader-User: 11196327406850766973
Date: Fri, 13 Jul 2012 15:17:16 GMT
Expires: Fri, 13 Jul 2012 15:17:16 GMT
Cache-Control: private, max-age=0
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
X-XSS-Protection: 1; mode=block
Content-Length: 133
Server: GSE


Line-based text data: application/x-www-form-urlencoded:

<dl><dt>s.0</dt>
<dd>Invalid stream name.</dd> <dt>a.0</dt>
<dd>Invalid stream name.</dd> <dt>i.0</dt>
<dd>Invalid item ID.</dd></dl>



I really hope someone can shed some light on this!

Thanks.


Quint

unread,
Aug 10, 2012, 3:32:49 AM8/10/12
to foug...@googlegroups.com
Hello,
 
When using Java HttpUrlConnection i received a response with "X-Reader-Google-Bad-Token true" in the header in combination with 400 Bad Request (and not 401).
Does "X-Reader-Google-Bad-Token" always mean that the token is expired? or can it also mean that the token is invalid some other way?
Because i request a new action token each request so i don't see how it can be expired.
This is what i do:
  1. Use Android AccountManager to request a Auth token (each time a new one). This token works for authenticated GET requests.
  2. Use the token to send a authenticated request for a action token. I successfully receive a action token.
  3. Use the action token for any edit post request to Google Reader but always fails with 400
All my post requests that edit something result in a 400 bad Request but all my GET requests are successful.
I also tried to not encode the action token param.
So what are the possible reasons for "X-Reader-Google-Bad-Token true" (+ 400 Bad Request)?
 
thanks.

Quint

unread,
Aug 12, 2012, 5:08:50 PM8/12/12
to foug...@googlegroups.com
Ok,

Everything  started to work after i changed the userid to "-".
problem solved.
Reply all
Reply to author
Forward
0 new messages