how to update a single contact's group membership with Google Contact API and .NET?

China☆狼群 提交于 2019-12-11 06:35:03

问题


I want to retrieve a specific contact, and update its group membership. I already know the self link of the contact. To get the specific contact, the developer's guide says to do this:

//The example assumes the ContactRequest object (cr) is already set up.

Contact c = cr.Retrieve<Contact>("http://www.google.com/m8/feeds/contacts/liz%40gmail.com/full/12345");

but when I compile this, I get an error:

Argument 1: cannot convert from 'string' to 'Google.Contacts.Contact'

If I change it to:

Contact c = cr.Retrieve<Contact>(new Uri("http://www.google.com/m8/feeds/contacts/liz%40gmail.com/full/12345"));

then it compiles, and seems to retrieve okay, but I'm unable to update the contact's group membership:

c.GroupMembership.Add(member2);
cr.Update(c);

as the cr.Update(c) line throws a GDataRequestException (400 Bad Request) with a response string of:

"Group membership information not supported"

What am I doing wrong?


回答1:


I figured out what I was doing wrong...

When retrieving the contact, I was using the "Id" property, instead of the "Self" property.

The "Id" property has "base" projection, while the "Self" property has "Full" projection.

Once I switched to using "Self" it worked properly.



来源:https://stackoverflow.com/questions/3486139/how-to-update-a-single-contacts-group-membership-with-google-contact-api-and-n

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!