2010-04-27 97 views
1

我使用下面的代码添加联系人的联系,但我得到了以下未处理的异常: Google.GData.Client.GDataRequestException:请求执行失败:http://www.google.com/m8/feeds/contacts/default/full添加与谷歌联系人.NET API

 GDataCredentials myCred = new GDataCredentials("myusername", "mypassword"); 
     RequestSettings myRequestSettings = new RequestSettings("macpapa-GoogleCodeTest3-1", myCred); 
     ContactsRequest myContactRequest = new ContactsRequest(myRequestSettings); 

     Contact myContact = new Contact(); 
     myContact.Title = "Be Dazzle"; 
     PhoneNumber myPhoneNumber = new PhoneNumber("805-453-6688"); 
     myPhoneNumber.Rel = ContactsRelationships.IsGeneral; 
     myPhoneNumber.Primary = true; 
     myContact.Phonenumbers.Add(myPhoneNumber); 

     EMail myEmail = new EMail("[email protected]", ContactsRelationships.IsHome); 
     EMail myEmail2 = new EMail("[email protected]", ContactsRelationships.IsWork); 
     myEmail.Primary = true; 
     myContact.Emails.Add(myEmail); 
     myContact.Emails.Add(myEmail2); 

     PostalAddress postalAddress = new PostalAddress(); 
     postalAddress.Value = "123 somewhere lane"; 
     postalAddress.Primary = true; 
     postalAddress.Rel = ContactsRelationships.IsHome; 
     myContact.PostalAddresses.Add(postalAddress); 


     Uri feedUri = new Uri(ContactsQuery.CreateContactsUri("default")); 
     Contact createdContact = myContactRequest.Insert<Contact>(feedUri, myContact); 

有什么建议吗?

+0

您正在使用错误的端点。 http://www.google.com/m8/feeds/contacts/default/full应该是http://www.google.com/m8/feeds/contacts/{your电子邮件}/full – Nepaluz 2013-11-29 01:48:40

回答

0

可能是Google API的MonoTouch(基于Mono)问题;见this后。

+0

该帖子是指“ (404)未找到'错误,而不是'错误的请求'... – 2011-04-12 08:08:34

0

这可能与您的联系人包含电子邮件地址有关:请参阅this question。删除myContact.Emails.Add行会有帮助吗?如果没有,是否删除所有myContact.Xxx.Add行帮助?