POST image file not working

Hi everyone!

I need your help because I can’t figure out what’s going wrong with my flow. I want to take a picture and POST it to a web api that I created that can count the objects in the files. It’s a FastAPI python webservice, in a docker image, pushed to Cloud Foundry on SAP BTP. It returns a JSON object.

But, in the logs of my webservice, I can’t find the request that AppGyver is supposed to make.
It returns an error on the second output, but rawError is an empty object.

The code I’m using for the POST:

const { photoFile } = inputs;

const url = "<url-to-my-webservice>/count/all";


const formData = new FormData();

const file = {
  uri: photoFile.path,
  size: photoFile.size,
  type: photoFile.mimeType,


formData.append("file", file);

try {
  const response = await fetch(url, {
    method: "POST",
    headers: {
      "Accept": "application/json",
      "Content-Type": "multipart/form-data",
    body: formData,

  console.log("response done!");

  if (!response.ok) {
    throw new Error("Unable to upload file to endpoint.");

  const parsed = await response.json();

  return [0, parsed];

} catch (error) {
  return [
      error: {
        code: "unknown",
        message: "Unknown error occurred while trying to upload file.",
        rawError: error,

The request expected by the webservice:

curl -X 'POST' \
  '<url-to-my-webservice>/count/all' \
  -H 'accept: application/json' \
  -H 'Content-Type: multipart/form-data' \
  -F 'file=@image_7cf556b0.jpg;type=image/jpeg'

I added a CORS middleware to my webservice to add CORS origins ‘*’ but it changed nothing.

Thank you for your help!


For anyone having the same issue, the problem came from the Android app, v. 4.3.3 on Android 9. My colleague tested on iPhone and it worked as expected.
That’s sad that there is so no error at all raised by the app. It’s almost impossible to debug, I lost 3 days on this.

1 Like