blue9manish / google-gdata

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

Group Insert fails when calling ContactRequest.Insert() - The remote server returned an error: (401) Unauthorized #564

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. I was trying to follow the .NET example given here to insert a new
group - 
http://code.google.com/apis/contacts/docs/3.0/developers_guide.html#CreatingGrou
ps
2. My code is as follows:

RequestSettings requestSettings = new RequestSettings(googleApplicationName, 
googleConsumerKey, googleSecretKey, userId, domain);

ContactsRequest contactsRequest = new ContactsRequest(requestSettings);

newGroup = new Group();
newGroup.Title = "new group";
newGroup.ExtendedProperties.Add(new ExtendedProperty()
                 {
                     Name = "My New Group",
                     Value = "Some more text.",
                 });

newGroup= contactsRequest.Insert(new 
Uri("https://www.google.com/m8/feeds/groups/default/full"), newGroup);
newGroupId = newGroup.Id;

3. Every time I execute the above code I get the following exception:
 - Execution of request failed: https://www.google.com/m8/feeds/groups/default/full
 - The remote server returned an error: (401) Unauthorized.

What is the expected output? What do you see instead?
I expected the group to be added without exception. 

What version of the product are you using? On what operating system?
1.9.0.0 on Windows 7 (x64)

Please provide any additional information below.

The confusing me thing for me is that I can retrieve and update groups
just fine so I think I have given my application sufficient scope to
do the insert (for the record it has been granted the following scope:
https://www.google.com/m8/feeds/).

I did some investigation in fiddler and noticed that the
xoauth_requestor_id query string parameter was not being sent on the
insert where it was on the update. I changed the code above to have
the xoauth_requestor_id as part of the URL and the insert worked!

My question is this a bug in my code (i.e. have I missed something
when creating the ContactRequest) or is it a bug in the Google.GData.Contacts 
API(i.e. should it automatically add this parameter when inserting a group or 
does the documentation example 
(http://code.google.com/apis/contacts/docs/3.0/developers_guide.html#CreatingGro
ups) have the incorrect Url (i.e. should have the xoauth_requestor_id as part 
of it)?

Thanks heaps if you can help me out a bit here!

Cheers,
Dave

Original issue reported on code.google.com by dave.wha...@gdev.intilecta.com on 4 Jan 2012 at 9:11

GoogleCodeExporter commented 8 years ago
Hi Dave,

Thanks for reporting this problem, it was actually due to a bug in one of the 
two FeedRequest.Insert overloads. I just committed a patch in rev. 1147 which 
should address your issue.

Claudio

Original comment by ccherub...@google.com on 9 Jan 2012 at 11:03

GoogleCodeExporter commented 8 years ago
Thanks!

Original comment by dave.wha...@gdev.intilecta.com on 9 Jan 2012 at 11:28