I am trying to add a contact to my Google contacts account. This is the code:
// Create new contact
Google.Apis.PeopleService.v1.Data.Person person = new Google.Apis.PeopleService.v1.Data.Person();
Name chef = new Name();
chef.GivenName = "FirstName";
chef.FamilyName = "FamilyName";
EmailAddress email = new EmailAddress();
email.Type = "work";
email.Value = "firstname.familyname@something.com";
person.EmailAddresses.Add(email);
person.Names.Add(chef);
ContactToCreate contactToCreate = new ContactToCreate();
contactToCreate.ContactPerson = person;
BatchCreateContactsRequest request = new BatchCreateContactsRequest();
request.Contacts.Add(contactToCreate);
request.ReadMask = "names";
BatchCreateContactsResponse reply = service.People.BatchCreateContacts(request).Execute();
Authentication and listing the Contact Groups works fine. If I add names or email addresses to the person object I get a Null Reference Exception.
Why?