Ebeo / google-gdata

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

I can't update the contact's WebSite,Event, Notes, NickName, Birthday #474

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. using the ClientLogin to access google contact, and get a contact entry
2. updating the email, IM, phone, address and Organization is OK
3. Failed to upate the contact's WebSite,Event, Notes, NickName, Birthday 
through the "entry.ContactEntry"
4. Both ContactsRequest.Update and ContactEntry.Update don't work

What is the expected output? What do you see instead?

the WebExption

What version of the product are you using? On what operating system?
My operating system is win7 x86

Please provide any additional information below.

Original issue reported on code.google.com by wangtest...@gmail.com on 31 Jan 2011 at 9:31

GoogleCodeExporter commented 8 years ago
I was using the C# with .Net Framework4

Original comment by wangtest...@gmail.com on 31 Jan 2011 at 9:37

GoogleCodeExporter commented 8 years ago
Can you post a code of snippet that reproduces the issue?

Original comment by ccherub...@google.com on 31 Jan 2011 at 9:53

GoogleCodeExporter commented 8 years ago
I attached a cs file which include most my code.

Thanks!

Fei

Original comment by wangtest...@gmail.com on 31 Jan 2011 at 10:09

Attachments:

GoogleCodeExporter commented 8 years ago
Once you have a Contact instance, you simply have to run the following code to 
update its nickname.
Updating other fields is trivial, please let me know if it works for you:

// assume your contact entry is populated
Contact entry;

entry.ContactEntry.Nickname = "newnick";
ContactEntry updated = entry.ContactEntry.Update();

Original comment by ccherub...@google.com on 31 Jan 2011 at 3:03

GoogleCodeExporter commented 8 years ago
I use below code , the first update is OK, the second throw exception, please 
seen my attached screen snap-shot  
try
                {
                    entry.ContactEntry.Update();
                    entry.ContactEntry.Nickname = "Nickname";
                    GDataContacts.ContactEntry updated = entry.ContactEntry.Update();
                }
                catch (Exception e)
                {
                    string error = e.ToString();
                }

Original comment by wangtest...@gmail.com on 1 Feb 2011 at 1:09

Attachments:

GoogleCodeExporter commented 8 years ago
 The first Update is OK, the second is exception
try
                {
                    entry.Emails.Add(new GExtensions.EMail("skyfei2@Gmail.Com", GExtensions.ContactsRelationships.IsOther));
                    entry.ContactEntry.Update();
                    entry.ContactEntry.Nickname = "Nickname";
                    GDataContacts.ContactEntry updated = entry.ContactEntry.Update();
                }
                catch (Exception e)
                {
                    string error = e.ToString();
                }

Original comment by wangtest...@gmail.com on 1 Feb 2011 at 1:23

GoogleCodeExporter commented 8 years ago
According to your screenshot you are getting a 412 Precondition Failed error, 
which means that you are trying to update an outdated entry:

http://code.google.com/intl/it/apis/contacts/docs/2.0/developers_guide_java.html
#Updating

After you call Update() on an entry you have to use the returned object for all 
following updates. To be clear, your code in the try block should look like:

entry.Emails.Add(new GExtensions.EMail("skyfei2@Gmail.Com", 
GExtensions.ContactsRelationships.IsOther));
GDataContacts.ContactEntry updated = entry.ContactEntry.Update();
updated.Nickname = "Nickname";
updated = updated.Update(); // reusing the same instance for future updates

Original comment by ccherub...@google.com on 1 Feb 2011 at 9:51

GoogleCodeExporter commented 8 years ago

Original comment by ccherub...@google.com on 4 Feb 2011 at 11:34