Google People API: Invalid JSON payload received (Postman)

Viewed 373

Working and trying to test the Google People API in postman, and running into the following error.

>   "error": {
>     "code": 400,
>     "message": "Invalid JSON payload received. Unknown name \"personFields\": Cannot bind query parameter. Field 'personFields'
> could not be found in request message.",
>     "status": "INVALID_ARGUMENT",
>     "details": [
>       {
>         "@type": "type.googleapis.com/google.rpc.BadRequest",
>         "fieldViolations": [
>           {
>             "description": "Invalid JSON payload received. Unknown name \"personFields\": Cannot bind query parameter. Field
> 'personFields' could not be found in request message."
>           }
>         ]
>       }
>     ]   } }

Here is the GET request I am trying to run:

https://people.googleapis.com/v1/people:searchContacts?query=removedEmailForPrivacy@email.com&personFields=person.email_addresses

I have read through the google People Docs but do not quite understand what I am doing wrong. In the docs it mentions I need a personFields query param, yet it is throwing the error above. I assume my formatting is wrong in some sense, but there aren't a ton of concrete examples I could find online.

For more context, I am attempting to search through the user's contact book and try and find the email address, and return pertinent information. Any help would be appreciated.

1 Answers

If what you are looking to do is search through another user's contact book instead you need to use the endpoint below:

GET https://people.googleapis.com/v1/{resourceName=people/*}/connections

As documented here this is the one to be used to achieve what you need:

"... Provides a list of the authenticated user's contacts ..."

Using the above this is the URL you will need in Postman:

https://people.googleapis.com/v1/people/me/connections?pageSize=300&personFields=emailAddresses

Where:

Me = the authenticated user.

PageSize = can be any number from 1 to 1000

Something to note:

  1. If you would like to add other personFields attributes, you can do so by separating them with commas. Like: personFields=emailAddresses,phoneNumbers
  2. You did not mention whether the other account you want to check is a free Gmail.com account or a Google Workspace one.
  3. If the latter is your case. you will need to impersonate the user to be able to access the user's contact list. I tested on my end, but I am not really sure how to go about doing that on Postman. If impersonation is not done you will only be able to use: "me" as the required resourceName parameter.
Related