0

I'm getting Http 429 Error when request to create a lot of message at the same time using Google Chat API. What is the limit of instant maximum request? Why am I getting this error.How can I solve this?

Note: I checked to quota page. "https://console.cloud.google.com/apis/api/chat.googleapis.com/quotas?"

But

"Write requests per minute":

Limit:6000, Usage:405

Sample code block:

 from oauth2client.service_account import ServiceAccountCredentials
 from googleapiclient.discovery import build
 from googleapiclient.errors import HttpError

 def get_client(service):
    scopes_chat = 'https://www.googleapis.com/auth/chat.bot'

    if service == "hangouts":
     credentials = ServiceAccountCredentials.from_json_keyfile_name(s_account, scopes_chat)
       return build('chat', 'v1', http=credentials.authorize(Http()), cache_discovery=False)

def send_alert_chat_notification(messages_with_product):
    try:
        hchat = get_client("hangouts")

        messages = messages_with_product[product]
        for message in messages:
            hchat.spaces().messages().create(
                        parent=space_name,
                        body=message).execute()
    except HttpError as e:
        logger.error("HTTP Error: Status: {}, Error: {}".format(str(e.resp.status), str(e)))
        return e

Error:

ERROR - HTTP Error: Status: 429, Error: <HttpError 429 when requesting https://chat.googleapis.com/v1/spaces/***/messages?alt=json returned "Resource has been exhausted (e.g. check quota).". Details: "Resource has been exhausted (e.g. check quota).">

  • Usually a 429 error message means that you are making too many requests in a short period of time? Have you tried including exponential backoff to see if that allows the request to be made? – Gabriel Carballo Jun 24 '22 at 20:47
  • This is the example of this [exponential backoff algorithm](https://cloud.google.com/iot/docs/how-tos/exponential-backoff) – Gabriel Carballo Jun 24 '22 at 21:01

0 Answers0