Closed GoogleCodeExporter closed 8 years ago
I was using the C# with .Net Framework4
Original comment by wangtest...@gmail.com
on 31 Jan 2011 at 9:37
Can you post a code of snippet that reproduces the issue?
Original comment by ccherub...@google.com
on 31 Jan 2011 at 9:53
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:
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
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:
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
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
Original comment by ccherub...@google.com
on 4 Feb 2011 at 11:34
Original issue reported on code.google.com by
wangtest...@gmail.com
on 31 Jan 2011 at 9:31