I'm following this article to create a message in Google Chat via services account. However when I compile the code, I got the following message:
Traceback (most recent call last): File "googlechat-api.py", line 27, in resp = chat.spaces().messages().create( File "C:\Users\tdi5539\Anaconda3\lib\site-packages\googleapiclient_helpers.py", line 134, in positional_wrapper return wrapped(*args, **kwargs) File "C:\Users\tdi5539\Anaconda3\lib\site-packages\googleapiclient\http.py", line 935, in execute raise HttpError(resp, content, uri=self.uri) googleapiclient.errors.HttpError: <HttpError 404 when requesting https://chat.googleapis.com/v1/spaces/AAAAcE3QeHo/messages?alt=json returned "Invalid project number.". Details: "Invalid project number.">
Could anyone explain for me what is the problem?
Here is my code by the way:
from httplib2 import Http
from oauth2client.service_account import ServiceAccountCredentials
from googleapiclient.discovery import build
scopes = 'https://www.googleapis.com/auth/chat.bot'
credentials = ServiceAccountCredentials.from_json_keyfile_name(
'credentials.json', scopes)
chat = build('chat', 'v1', http=credentials.authorize(Http()))
resp = chat.spaces().messages().create(
parent='spaces/AAAAcE3QeHo', # use your space here
body={'text': 'Test message'}).execute()
print(resp)