googleapis / googleapis/google-api-nodejs-client
POST API call to Chat V1 messages not working
- Dominant language
- TypeScript
- Stars
- 12.2k
- Forks
- 2k
- Avg merge
- 1d 9h
- Merged PRs (30d)
- 24
Description
Thanks for stopping by to ask us a question! Please make sure to include:
- What you're trying to do
Trying to follow documentation in how to request extra configurations to the user, I'm following the docs to use [ActionResponse](https://developers.google.com/chat/api/reference/rest/v1/spaces.messages#actionresponse) but when I use the client I get `Error: Message cannot be empty.` and if I try the API using fetch I get `400 Bad Request`. Hoping I get this

but I'm not getting anything
- What code you've already tried
I've tried the following using the client
```javascript
import { chat, auth } from '@googleapis/chat';
const googleAppAuth = new auth.GoogleAuth({
// Specify required scopes.
scopes: ['https://www.googleapis.com/auth/chat.bot'],
});
const chatAppClient = await chat({
version: 'v1',
auth: googleAppAuth,
});
chatAppClient.spaces.messages.create({
parent: space,
requestBody: {
actionResponse: {
type: 'REQUEST_CONFIG',
url: 'https://google.com',
},
},
});
```
and using raw api call:
```javascript
const token = await googleAppAuth.getAccessToken();
console.log(await fetchEndPoint(`https://chat.googleapis.com/v1/${eventData.space?.name}/messages`, {
body: JSON.stringify({
actionResponse: {
type: 'REQUEST_CONFIG',
url: 'https://google.com',
},
}),
method: 'POST',
headers: {
Authorization: `Bearer ${token!}`,
},
}));
```
`googleAppAuth` is using `ADC` with the `chat` scope.
- Any error messages you're getting
**PLEASE READ**: If you have a support contract with Google, please create an issue in the [support console](https://cloud.google.com/support/) instead of filing on GitHub. This will ensure a timely response.
Contributor guide
Assessment
This issue has not been assessed yet.