I am trying to get this example in Python working.
def get_msg():
creds = None
if os.path.exists('token.json'):
creds = Credentials.from_authorized_user_file('token.json', ['https://www.googleapis.com/auth/chat.spaces', 'https://www.googleapis.com/auth/chat.messages')
chat = build('chat', 'v1', credentials=creds)
result = chat.spaces().messages().list(name='spaces/123456789').execute()
print(result)
def main():
get_msg()
This error comes up:
Traceback (most recent call last):
File "C:\30_py\google\chat\test_chat.py", line 64, in <module>
main()
File "C:\30_py\google\chat\test_chat.py", line 57, in main
get_msg()
File "C:\30_py\google\chat\test_chat.py", line 46, in get_msg
result = chat.spaces().messages().list(name='spaces/123456789').execute()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'Resource' object has no attribute 'list'
I tested the authorization and the space name in the API explorer and it worked. I was able to get a list of spaces using a different endpoint so the credentials/token/logic works. However, I am stuck trying to get the endpoint working i.e. being able to fix this attribute error. Any ideas and recommendations are appreciated.
There is no
nameargument inlist(). You need to give space id toparentas"spaces/{space}". Use API Reference whenever in doubt.