2010-04-27 131 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行幫助?