"Invalid request token" while uploading image to server (ABI36_0_0RCTErrorDomain)

Hello,

I am trying to upload an image to my server but I get the following error :

Error processing request body: Error Domain=ABI36_0_0RCTErrorDomain Code=0 “Invalid request token.” UserInfo={NSlocalizedDescription=Invalid request token.}

Here is my code :

  let fileName = imagePath.split("/").pop();
  const photo = {
    uri: imagePath,
    type: "image/jpeg",
    name: fileName
  };

  const formData = new FormData();
  formData.append("photo", photo);

  const options = {
    method: "POST",
    body: formData,
    headers: {
      Accept: "application/json",
      "Content-Type": "multipart/form-data"
    }
  };

fetch(serverEndpoint, options);

I am using :

  • Expo 36
  • Testing on IOS device

I tried :

  • to downgrade to version 35 but still get the same issue (error message is then “ABI35_0_0…”)
  • to remove the “file://” prefix in the uri, but I still get the same error.

It works fine when replacing the “photo” by a text file, but the problem only occurs when attaching an image.

Would you have a solution or a workaround for this issue please ?
I just want to upload an image to my server.

Thanks !

2 Likes

I’ve the same issue, someone has a workaround ?

I am getting the same error message:

The error message is like this: Error processing request body: Error Domain=ABI37_0_0RCTErrorDomainCode=0 Invalid request Token. UserInfo={NSLocalizedDescription=Invalid request token.}

As one Stackoverflow question mentions, it works perfectly fine on iOS simulators. I updated my Expo, Expo-cli, and Expo Client installed on my iOS device, but it does not work.

The code was previously working without any problem.

Any fixes?

can someone post an end to end reproducible example of this? a simple minimal server we can run and the minimal code to reproduce this in expo client with that server. if you can do that we can try to help! i haven’t been able to reproduce it on my own

I’ve the same issue here with sdk36. The issue fires only on IOS when I turn my device and change its orientation from portrait to landscape while taking a picture with expo-camera