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

186
Visualizações
Sending media parameter is not working while sending it to kaleyra api through code

https://developers.kaleyra.io/docs/send-a-media-template-message-through-whatsapp

I am trying to send a media to kalerays api through my code. But it is not working when I pass from code. But When I hit the API from postman then it works fine.

async whatsappAPIWithAttachment(requestBody) {
     let api_key = "";
    if (requestBody.campaign) {
      api_key = "x";
    } else {
      api_key = "Y";
    }
    
    var data = qs.stringify({
      from: "xyz",
      to: "xyz",
      type: "mediatemplate",
      channel: "whatsapp",
      template_name: "xyz",
      params: '"name","vendor"',
      lang_code: "en",
      media_url: "http://www.africau.edu/images/default/sample.pdf",
    });

    var config: AxiosRequestConfig = {
      method: "post",
      url: "https://api.kaleyra.io/v1/HXIN1707222213IN/messages",
      headers: {
        "api-key": api_key,
        "content-type": "multipart/form-data",
      },
      data: data,
    };

    let response = await axios(config);
    return response.data;
  }
}

It gives me an enter image description hereerror request failed with status code 400. Here I have replaced X, Y, and XYZ with actual parameters. So Inputs are correct but still get an error saying 'E413', message: 'Invalid/incorrect inputs.

about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

As per sample request in kaleyra documentation, they have used

--header 'Content-Type: application/json'

while you are passing

"content-type": "multipart/form-data",

pls correct it and try.

about 4 years ago · Juan Pablo Isaza Relatório

0

how about using double quote strings for param value

params: "\"name\",\"vendor\""
about 4 years ago · Juan Pablo Isaza Relatório
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