Getting Network Request Failed error

I’m trying to upload an image file to the Backendless Files API which requires the body of the request to be of type multipart/form-data.

I created a quick JS flow function to format the body (I think I read from another post that otherwise it isn’t possible to send form requests with the existing AppGyver functions/UI) and linked it to the output of a Take photo flow function.

I managed to get it working yesterday (this was prior to updating the preview app to the latest version, but not sure if this is related) but now it isn’t working at all. When using the debugger, I keep getting the following error: [error] [function2:f3a92b32.cc28d8] TypeError: Network request failed plus a very long error object which starts like this:

errrr ▶Object {id: "f3a92b32.cc28d8", type: "function2", z: "da12f1b9.1d9c", _closeCallbacks: Array[1], _alias: "instance_61843ad8.6bbba4_e7923c2_ef97bc"…}

I’ve tested the API separately using cURL and it works. The endpoint is of the form:


Here is the JavaScript code for my flow function, where the file input is an image object made of six properties (name, path, mimeType, size, createdAt, modifiedAt).

const { file, token, url } = inputs;

const formData = new FormData();

formData.append("image", file);

const response = await fetch(url, {
  method: "POST",
  headers: {
    "Accept": "application/json",
    "Content-Type": "multipart/form-data",
    "user-token": token,
  body: formData,
.then(res => { 
  return res.json()
.then(data => {
  return data;

console.log(response); // printing to see error in the console as using catch and console.error returns an empty object.

return { result: response };

What’s happening here and how can I fix it? Thanks!

After doing some digging I found the solution to the error myself, which was caused by incorrect formatting of the request body. I’m marking this as solve, but it can be deleted if wished.

@Juan_Giraldo - Hi Juan, do you have more detiails about how you solved this please , specifically the request body /? thanks very much

Hey @Sim_Sim, the code here was an earlier non-working version of the script I ended up using, which you can find on my other reply here: Uploading image to backendless.