1
votes

I’m trying to learn how to use Google’s People API. I’ve already understood the OAuth 2 basics and know how to get a list of contacts.

The next step is to update some property in contact information. I’m using https://developers.google.com/people/ as reference.

In the section of managing contacts, the only example is in Java, I couldn’t find a similar match in C#. https://developers.google.com/people/v1/write-people

Is it possible update contacts with the C# API? If yes, can someone can give me link to an example, please?

1

1 Answers

2
votes

Unfortunately, I haven't found any example, but it should be something like this

var service = new PeopleService (new BaseClientService.Initializer()
{
    HttpClientInitializer = credential,
    ApplicationName = "APP_NAME",
});

Person contactToCreate = new Person();
List<Name> names = new List<Name>();
names.Add(new Name() {GivenName = "John", FamilyName = "Doe"});
contactToCreate.Names = names;

Google.Apis.PeopleService.v1.PeopleResource.CreateContactRequest request =
 new Google.Apis.PeopleService.v1.PeopleResource.CreateContactRequest(service, contactToCreate);
Person createdContact = request.Execute();

You can find more information here: Class reference. But it's a bit unclear.