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

134
Vistas
How can I post a photo and caption in the same publish on a facebook group api using FormData and axios?

Someone could help me, I'm trying to send a photo and caption into a group, but isn't working! I'd like send the photo that I recieve as base64 and send to a facebook group api.

What I'm doing? I got the base64 then convert into buffer and write it on a local disk, then I read it into a formdata. I load the data into a form this way =>

const form = new FormData();
    const fileContent = Buffer.from(url as any, 'base64');

    fs.writeFile('../tmp', fileContent, (err) => {
      if (err) return console.log(err)
    })


form.append('groupId', groupId)
 form.append('caption', caption) 
form.append('image ', fs.createReadStream('../tmp'))

In below is the axios configurations and request

 await client.post(`${config.facebook.BASE_URL}/${groupId}/photos`, form, {
  headers: {
    ...form.getHeaders(),
    Authorization: `OAuth ${config.facebook.token}`,
    'content-type': 'multipart/form-data',
    file_type: "image/jpeg",
  }

})

Note: This way I got the Error: Request failed with status code 500

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

0

I already resolved this although I changed de way that the file came to me, instead of receiving the image in base64 I'm receiving a signed url from google storage, and on the form.append, it's necessary to pass the name and the extension of the file, like this => form.append('source', image, 'file.jpg'); of course together with the other params and axios' configurations

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