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

200
Vistas
How to send Base64 to API

I am ultimately trying to send a fax with the Vitelity API. I have an API on EC2 that I am calling from my React Native app:

// Encoding to Base64
const encodeB64 = () => {
    RNFS.readFile(croppedImage, 'base64').then(res => {
      sendB64(res);
    });
  };

const sendB64 = b64 => {
    let myHeaders = new Headers();
    myHeaders.append('Content-Type', 'application/json');

    let raw = JSON.stringify({
      data1: b64, // 'jdl3439fdjsle/jjug'
      login: {login},
      pass: {pass},
      faxnum: {destinationNum},
      faxsrc: {sourceNum},
      recname: 'Test',
      file1: 'testfax.jpg',
    });

    let requestOptions = {
      method: 'POST',
      headers: myHeaders,
      body: raw,
      redirect: 'follow',
    };

    fetch(API_URL, requestOptions)
      .then(response => response.text())
      .then(result => console.log(result))
      .catch(error => console.log('error', error));
  };

However, this returns an error cannot POST. If, instead of b64, I change data1's value to something like jdl3439fdjsle/jjug, everything is great.

Do I need to do something special to b64 before I can send it?

My Base64 looks like: /9j/4AA{1.2m more chars}uB//9k=. I've pasted it into a converter and it produces the correct image.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

I geuss you have to use a Multipart Form with multipart/form-data as content-type headers if you want to send images. See also this question.

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