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

229
Vistas
JS POST Payload - You have to specify either `source` or `file` form data field

For some reason this works fine in postman when i manually select a file from my PC to upload, but when i try to run in production off webform on my website i get a 400 response with the message "You have to specify either source or file form data field."

What is wrong with this code? This is verbatim from the postman "code" menu and should mirror the successful request i can fire from postman.

//Front end

<input type="file" id="physical" name="physical" value="" placeholder="Click or drag a file to this area to upload." data-size="20">

//Back end

var physicalUpload = document.getElementById("physical").files[0];     
headers = {'Authorization': 'API-Key xxxxxxxxxxx','Content-Type': 'multipart/form-data'};
    
    //Create attachment
    var formdata = new FormData();
    formdata.append("file",physicalUpload);
  
  var requestOptions = {
  method: 'POST',
  headers: headers,
  body: formdata,
  redirect: 'follow'
  };
  
  
  let response = await fetch("https://api.xxxxxxx.com/public/v1/documents/"+docID+"/attachments/", requestOptions)
  .then(response => response.text())
  .then(result => {

    const obj = JSON.parse(result);
    console.log("attachmentID: "+obj.id);
    console.log("uuid: "+obj.uuid);
    

  })
  .catch(error => console.log('error', error));
  this.response = response;
  console.log("Response: "+this.response);
  
  return response;
about 4 years ago · Juan Pablo Isaza
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