使用 Google Contacts .NET API 添加联系人

发布于 2024-08-30 21:55:58 字数 1795 浏览 3 评论 0原文

我使用以下代码添加联系人,但出现以下未处理的异常: 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

我是男神闪亮亮 2024-09-06 21:55:58

可能是 Google API 的 Monotouch(基于 Mono)问题;请参阅这篇文章

Could be a Monotouch (based on Mono) problem with Google API; see this post.

不甘平庸 2024-09-06 21:55:58

这可能与您的联系人包含电子邮件地址有关:请参阅此问题。删除 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 the myContact.Xxx.Add lines help?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文