Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

191
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

0

how about using double quote strings for param value

params: "\"name\",\"vendor\""
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda