0

I have a bunch of people I would like to add as Google Contact. For each of them, I have the google account ID.

I would like to use Google People API, but so far I've failed. Here's what I've tried :

-provide Google Id as ResourceName (pre-formating people/id). I got a 400 error with message : "Request person should not have a resource name."

-provide Google Id as a metadata, formating it properly in sources[0].id. I also got a 400 error with message : "Request contains an invalid argument."

I'm kinda stuck here, does anyone have an idea ? Thanks a lot !

2
  • Hi Clément, can you provide an example of a Google Id you have? For example, one I have looks like this people/c2837451336675212477 These are generated by the Google API call when creating a contact; you should not be providing these to a create call. Rather you provide the contacts details and Google will create the contact and return the Id. Also, what language are you using? I used PHP and provide an example of creating a new contact
    – Jordan
    Commented Oct 3, 2019 at 8:18
  • Hi Jordan, thanks for you answer. The Google Id is specific to each Google Account and looks like that : 105857236219149931842. You can use it as resourceName to call the API and retrieve information if you format it people/105857236219149931842, but it's not a resourceName. The resourceName is a different resource, not specific to a Google Account, but to a Google Contact. It means a person can have different resourceName, and as you stated you can't add contact by resourceName since the resourceName is not pre-existant but generated when you create a contact. Commented Oct 3, 2019 at 10:04

1 Answer 1

0

I also wanted to add contacts using the people API, based on the directory profile. I got this working by using the following body:

body = {
    "names": [{"familyName": "Doe"}],
    "emailAddresses": [
        {"metadata": {"primary": True}, "value": "[email protected]"}
    ],
}

The contact was added and when I compared the contact with another contact that I created manually based on the directory, the properties were the same.

My conclusion is that, by adding the G Suite primary address, Google will figure it out on its own.

Not the answer you're looking for? Browse other questions tagged or ask your own question.