.NET中的Google联系API

时间:2012-12-25 16:00:42

标签: c# google-api google-contacts

我是Google API for Google Contacts的初学者。我已实施列出所有联系人并添加新联系人。我现在有一个更新\编辑和删除联系人的问题。我尝试了很多网络示例而没有成功。你能救我吗?

 public static void EditContact(string id, string name, StructuredPostalAddress address)
 {
    ContactsQuery query = new ContactsQuery(ContactsQuery.CreateContactsUri("default"));

    ContactsFeed feed = GContactService.Query(query);

    foreach (ContactEntry entry in feed.Entries)
    {
        foreach (EMail email in entry.Emails)
        {
            if (email.Address == id)
            {
                Organization org = new Organization();
                org.Rel = ContactsRelationships.IsWork;
                org.Title = "President, CEO";
                org.Name = "John Doe Enterprises";
                org.Primary = true;
                entry.Name = new Name() { FullName = name };
                entry.PostalAddresses.Add(address);
                entry.Organizations.Add(org);
                // error:
                // Execution of request failed
                ContactEntry updatedEntry = (ContactEntry)entry.Update();
            }
        }
    }
}
  

未处理的类型异常   发生了'Google.GData.Client.GDataRequestException'   Google.GData.Client.dll

     

其他信息:执行请求失败:

0 个答案:

没有答案