Megabytemb / google-gdata

Automatically exported from code.google.com/p/google-gdata
0 stars 0 forks source link

"411 length required" when inserting a new Contact using oauth2 #616

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Create a new VS2008 CS console application.
2. Add references to Google.GData.Client, Google.GData.Contacts, 
Google.Gdata.Extensions.
3. Add the next "using" lines:
    using Google.Contacts;
    using Google.GData.Contacts;
    using Google.GData.Client;
    using Google.GData.Extensions;
4. Copy the CreateContact() method from 
https://developers.google.com/google-apps/contacts/v3/.
5. Add the next lines to the Main method:
    OAuth2Parameters parameters = new OAuth2Parameters();
    parameters.ClientId = @"...";
    parameters.ClientSecret = @"...";
    parameters.RedirectUri = @"urn:ietf:wg:oauth:2.0:oob";
    parameters.Scope = @"https://www.google.com/m8/feeds/";
    parameters.AccessCode = "";
    parameters.AccessToken = "...";
    parameters.RefreshToken = "...";
    RequestSettings settings = new RequestSetting("Priority",parameters);
    ContactsRequest cr = new ContactsRequest(settings);
    CreateContact(cr);
6. Replace ... with appropiate oauth2 values.
7. Build & Run.

What is the expected output? 
The new contact was successfully inserted.

What do you see instead?
A GDataRequestException is received.
It includes a server error "(411) Length Required",
and the next string: "POST requests require a Content-length header.  That’s 
all we know."

Please use labels and text to provide additional information.

Original issue reported on code.google.com by marc...@eshbel.com on 16 Aug 2012 at 6:25

Attachments:

GoogleCodeExporter commented 9 years ago
I can't reproduce the issue.

I copied the CreateContact() method from the docs and the only problem with it 
was that no address was specified for the gd:im field.
I added that to the method and it worked correctly.

I'm closing this issue. If you are still getting the 411, please capture the 
request and response with Fiddler and add them here to reopen it.

Original comment by ccherub...@google.com on 17 Aug 2012 at 6:31

GoogleCodeExporter commented 9 years ago
I think the problem reproduces if the refreshtoken needs refreshing.

A quick workaround is to manually refresh the refreshtoken before executing any 
method in google.gdata.client by adding the next line before the 
RequestSettings construction:
OAuthUtil.RefreshAccessToken(parameters);

Original comment by marc...@eshbel.com on 19 Aug 2012 at 5:33