Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

293
Visualizações
Status code: 422 (error: {type: 'validation', message: 'Invalid message'})

I am trying to write the following curl post function with basic authentication in vanilla javascript.

curl -X POST \
  https://api.livechatinc.com/v3.3/agent/action/list_chats \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer <your_access_token>' \
  -d '{}'

This is my code in javascript.

    (async () => {
      const rawResponse = await fetch(url, {
        method: 'POST',
        headers: {
          'Content-Type' : 'application/json',
          'Authorization': 'Basic ' + btoa(username+":"+password)
        },
        body: {
         "filters.group_ids" : "1",
         "limit" : 1
        }
      });
      const content = await rawResponse.json();
      
      console.log(content);
    })();

I keep getting this error "error: message: "Invalid message" type: "validation""

The curl method works perfectly in postman. I have read the documentation about this error and tried removing the content type header. It did not work. Any help is appreciated.

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda