'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?
Solution 1:[1]
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.
Solution 2:[2]
According to Google's documentation:
Specifying
READ_SOURCE_TYPE_PROFILEwithout specifyingREAD_SOURCE_TYPE_CONTACTis not permitted.
Setting both READ_SOURCE_TYPE_CONTACT and READ_SOURCE_TYPE_PROFILE should resolve this issue.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | ale13 |
| Solution 2 | Jeremy Caney |
