Mark
Mark

Reputation: 440

Where to find sample C# .NET code for Google's People API?

I have an installed app that uses .NET and the Contacts API. I'm trying to convert to the People API. I'm having trouble getting started and finding a sample that shows how to use People API with the .NET library. For example, the samples listed under the Peoples API documentation doesn't include .NET. Where can I find a .NET sample for the People API?

Upvotes: 1

Views: 1758

Answers (1)

Zunair
Zunair

Reputation: 1195

Start with this ;)

https://googleapis.dev/dotnet/Google.Apis.PeopleService.v1/latest/api/Google.Apis.PeopleService.v1.html

Get the nuget called Google.Apis.PeopleService.v1 https://github.com/googleapis/google-api-dotnet-client

Also, I'm sure you have seen this https://developers.google.com/people/v1/profiles It has some .net examples.

What exactly are you trying to accomplish? I am just about to complete converting an app that used contacts API to people API using a service account for the company.

ps. I can't copy the whole namespace in the answer hense answer with a link.

Edited: 20210608

        Person person = new Person();

        person.EmailAddresses = new List<EmailAddress>();
        person.EmailAddresses.Add(new EmailAddress() { Type = "work", Value = "[email protected]" });
        person.Names = new List<Name>();
        person.Names.Add(new Name() { FamilyName = "Lname2", GivenName = "Fname" });

        // link to peopleService code can be found in the comments
        // it's basically initializing PeopleServiceService with service account credentials
        Person retVal = peopleService.People.CreateContact(person).Execute();

Upvotes: 1

Related Questions