Android Google Calendar Service getting 鈥?00 Bad Request鈥?using ClientLogin

by Karim Varela » Thu, 19 May 2011 07:56:39 GMT


Sponsored Links
 I'm new to Google web services and not sure why my request is not
going through. I'm able to get my Auth token no problem using the
following code:

HttpClient client = new DefaultHttpClient();
String postURL = "https://www.google.com/accounts/ClientLogin";
HttpPost post = new HttpPost(postURL);
List<NameValuePair> params = new ArrayList<NameValuePair>();
params.add(new BasicNameValuePair("Email",
"karim.var...@gmail.com"));
params.add(new BasicNameValuePair("Passwd", "XXXXXX"));
params.add(new BasicNameValuePair("service", "cl"));
params.add(new BasicNameValuePair("accountType", "GOOGLE"));

UrlEncodedFormEntity ent = new
UrlEncodedFormEntity(params,HTTP.UTF_8);
post.setEntity(ent);
HttpResponse responsePOST = client.execute(post);
HttpEntity resEntity = responsePOST.getEntity();
if (resEntity != null) {
    String response = EntityUtils.toString(resEntity);
    authKey = response.substring( response.indexOf("Auth="),
response.length());
    authKey = authKey.replace( "Auth=","" );
 }


Then, I'm trying to make a simple call to get all the calendars for
karim.var...@gmail.com. As far as I know, it should be a simple GET to
https://www.google.com/calendar/feeds/default/allcalendars/full making
sure to set the header as get.setHeader("Authorization", "GoogleLogin
auth=" + authKey );. This is what I have:

HttpClient client = new DefaultHttpClient();
String getURL = "https://www.google.com/calendar/feeds/default/
allcalendars/full";
HttpGet get = new HttpGet(getURL);
get.setHeader("Authorization", "GoogleLogin auth=" + authKey );
get.setHeader("Content-Type", "application/atom+xml");
HttpResponse responseGet = client.execute(get);
HttpEntity resEntityGet = responseGet.getEntity();
if (resEntityGet != null) {
    String response = EntityUtils.toString( resEntityGet );
}

When this code is executed, however, I'm getting a "400 Bad Request"
and then farther down it says "Your client has issued a malformed or
illegal request." Can anybody please help me with this?

-- 



Other Threads

1. AutoCompleteTextView for contacts

Hi,
How can I have a AutoCompleteTextView which autocompletes from the
Contacts, the way the Messaging app does?

It's possible to read the contacts from the Contacts provider, and use
this for the AutoCompleteTextView's adapter. But, how does the
Messaging app show two lines with the contact name and the type of
information (home, mobile, other) in gray?

Thanks!
--~--~---------~--~----~------------~-------~--~----~

2. Tmobile Android touch screen not working after 2 minutes broswing.



If by "hard reset" you mean "factory reset", rest assured you won't
have to SIM-unlock your phone again.
You *will* have to link to your Google account but that's another thing.

Cheers

--~--~---------~--~----~------------~-------~--~----~

3. error in creating object of FileTransferManager manager

4. How to Add Hardware Support to Android?

5. Highlight an Item In listactivity

6. project is not running on sdk

7. Is it safe to Install HTC/Dream/G1 builds created from git repo?