Eugene Loy
Eugene Loy

Reputation: 12446

Google People API: reading "other contacts" with addresses

I need to read addresses of "other contacts". Docs say that in order to do this, READ_SOURCE_TYPE_PROFILE should be set. However, when doing it like this:

service = googleapiclient.discovery.build('people', 'v1', credentials=credentials)
resource = service.otherContacts()

request = resource.list(
    readMask='names,emailAddresses,phoneNumbers,addresses',
    sources='READ_SOURCE_TYPE_PROFILE',
    pageSize=1000
)

request.execute()

... I am getting the following error: Must request READ_SOURCE_TYPE_CONTACT. Full traceback:

Traceback (most recent call last):
  File "C:\Users\Leo\workspace\gapitest\main.py", line 22, in <module>
    response = request.execute()
  File "C:\Users\Leo\workspace\gapitest\venv\lib\site-packages\googleapiclient\_helpers.py", line 131, in positional_wrapper
    return wrapped(*args, **kwargs)
  File "C:\Users\Leo\workspace\gapitest\venv\lib\site-packages\googleapiclient\http.py", line 937, in execute
    raise HttpError(resp, content, uri=self.uri)
googleapiclient.errors.HttpError: <HttpError 400 when requesting https://people.googleapis.com/v1/otherContacts?readMask=names%2CemailAddresses%2CphoneNumbers&sources=READ_SOURCE_TYPE_PROFILE&pageSize=1000&alt=json returned "Must request READ_SOURCE_TYPE_CONTACT". Details: "Must request READ_SOURCE_TYPE_CONTACT">

What am I doing wrong?

Upvotes: 1

Views: 465

Answers (2)

Offir Bakshitz
Offir Bakshitz

Reputation: 1

According to Google's documentation:

Specifying READ_SOURCE_TYPE_PROFILE without specifying READ_SOURCE_TYPE_CONTACT is not permitted.

Setting both READ_SOURCE_TYPE_CONTACT and READ_SOURCE_TYPE_PROFILE should resolve this issue.

Upvotes: 0

ale13
ale13

Reputation: 6072

It seems that what you are seeing might be a bug.

I have filed this issue on Issue Tracker here so feel free to star it and eventually add a comment, as any updates shall be posted there.

Upvotes: 1

Related Questions