googleapis / googleapis/google-api-nodejs-client

POST API call to Chat V1 messages not working

Abierto
#3,379 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

priority: p3 type: question
Lenguaje dominante
TypeScript
Estrellas
12.3k
Forks
2k
Merge medio
1 d 9 h
PR fusionados (30 d)
24

Descripción

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 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
image
but I'm not getting anything

  • What code you've already tried

I've tried the following using the client


   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:

    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 instead of filing on GitHub. This will ensure a timely response.

Guía de contribución

Abrir la guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Línea de trabajo

Comienza con la documentación enlazada de ActionResponse y compárala con la llamada chatAppClient.spaces.messages.create y el ejemplo de fetch POST /v1/{space}/messages. Reproduce las respuestas reportadas “Message cannot be empty” y 400 y, a continuación, determina el comportamiento esperado de la solicitud y documenta o resuelve la discrepancia.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
typescript
Área
api
Tipo de issue
Error
Dificultad
4/5
Tiempo estimado
3-5 días
Estado de actividad
Estancado
Claridad
Necesita aclaración
Aptitud para principiantes
20/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.