使用 Google Contacts .NET API 添加联系人
我使用以下代码添加联系人,但出现以下未处理的异常: Google.GData.Client.GDataRequestException:执行请求失败:http://www .google.com/m8/feeds/contacts/default/full
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);
有什么建议吗?
I am using the following code to add a contact, but I get the following unhandled exception:
Google.GData.Client.GDataRequestException: Execution of request failed: http://www.google.com/m8/feeds/contacts/default/full
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);
Any suggestions?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
可能是 Google API 的 Monotouch(基于 Mono)问题;请参阅这篇文章。
Could be a Monotouch (based on Mono) problem with Google API; see this post.
这可能与您的联系人包含电子邮件地址有关:请参阅此问题。删除
myContact.Emails.Add
行有帮助吗?如果没有,删除所有myContact.Xxx.Add
行是否有帮助?It may be related to the fact that your contact includes an email address: see this question. Does removing the
myContact.Emails.Add
lines help? If not, does removing all themyContact.Xxx.Add
lines help?