我正在使用google api 3.0版,我可以使用c#成功登录gmail。并且在我能够成功检索联系人之后也获得访问代码。之后,我想添加新的联系人,但我无法使用以下代码创建新的联系人。 public static联系CreateContacts(ContactsRequest cr) { 联系newEntry = new联系方式();
// Set the contact's name.
newEntry.Name = new Name()
{
FullName = "Harsh Desai",
GivenName = "Harsh",
FamilyName = "Desai",
};
newEntry.Content = "Notes";
// Set the contact's e-mail addresses.
newEntry.Emails.Add(new EMail()
{
Primary = true,
Rel = ContactsRelationships.IsHome,
Address = "h@gmail.com"
});
newEntry.Emails.Add(new EMail()
{
Rel = ContactsRelationships.IsWork,
Address = "ha@example.com"
});
// Set the contact's phone numbers.
newEntry.Phonenumbers.Add(new PhoneNumber()
{
Primary = true,
Rel = ContactsRelationships.IsWork,
Value = "9825277788",
});
newEntry.Phonenumbers.Add(new PhoneNumber()
{
Rel = ContactsRelationships.IsHome,
Value = "0123654789",
});
// Set the contact's IM information.
newEntry.PostalAddresses.Add(new StructuredPostalAddress()
{
Rel = ContactsRelationships.IsWork,
Primary = true,
Street = "1/Radhakrishna",
City = "Surat",
Postcode = "395007",
Country = "India",
});
// Insert the contact.
Uri feedUri = new Uri(ContactsQuery.CreateContactsUri("default"));
Contact createdEntry = cr.Insert(feedUri, newEntry);
Console.WriteLine("Contact's ID: " + createdEntry.Id);
return createdEntry;
}
我在这一行收到错误联系createdEntry = cr.Insert(feedUri,newEntry)。 错误是远程服务器返回错误:(400)错误请求。