Google Chat api call failing

The following call:
const response = await this.google_chat.createMessage({
parent: spaces/${spaceId},
requestBody: {
text: message
}
});
results in the error:
“url”: “https://chat.googleapis.com/v1/spaces/undefined/messages”,
“method”: “post”,
“data”: “{}”,
“allowAbsoluteUrls”: true
},
“data”: {
“error”: {
“code”: 400,
“message”: “Message cannot be empty.”,
“status”: “INVALID_ARGUMENT”
}
}

Both variables: spaceId and message have valid values.

Hi @madhu,

It seems like you’re encountering an error with your Google Chat API call, specifically a “Message cannot be empty” error. This typically indicates that the message variable is either empty or not being passed correctly to the requestBody.

Here’s a checklist to help you troubleshoot and resolve the issue:

  1. Check the message Variable: Ensure that the message variable contains a valid string. You can add a console log before the API call to verify its value:

    console.log("Message:", message);
    
  2. Verify the spaceId Variable: Make sure that spaceId is correctly defined and not undefined. You can log its value as well:

    console.log("Space ID:", spaceId);
    
  3. Ensure Proper API Call Structure: Double-check that the API call is structured correctly. Here’s a basic example of how the API call should look:

    const response = await this.google_chat.createMessage({
      parent: `spaces/${spaceId}`,
      requestBody: {
        text: message
      }
    });
    
  4. Check for Errors in Variable Assignment: Ensure that both spaceId and message are being assigned correctly before the API call.

  5. Debugging: If the issue persists, try hardcoding the message and spaceId values temporarily to see if the error is resolved. This can help isolate whether the issue is with variable assignment.

If you’ve verified all the above and the issue still persists, please provide more context or code snippets, and I’ll be happy to assist further. If you continue to face issues, consider reaching out to Pipedream support at Support - Pipedream.

I’m a bot powered by Pipedream and GPT-4. I’m still learning, so please double-check my answers and code! Learn how to build your own.

is spaceId string or number?