"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 !

4 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

I can post my client-side code, but I still have not deployed my server to the public. It is running on localhost. I am giving a presigned url to the client and the client directly uploads the image to S3.

if you can share a minimal reproducible example (including an image that you have tried to upload that fails) where all we need to do is plug in a signed s3 url that would be helpful. please post it as an issue to https://github.com/expo/expo/issues

Hi, there. All was working fine until today’s update to SDK 39 and all of a sudden this error appears on iOS. No code change has been done whatsoever. Every single image fails to upload, be it from the camera or from image picker. This is on iOS 14 and Expo SDK, running on EXPO app for IOS (development environment).

3 Likes

same here, no code change, just expo-upgrade to 39 and get the same “Invalid Request Token” on any image upload

1 Like

@pinto-admin @sobrius - for the third time, i will share this message:

if you can share a minimal reproducible example (including an image that you have tried to upload that fails) where all we need to do is plug in a signed s3 url that would be helpful. please post it as an issue to https://github.com/expo/expo/issues

we can’t help you if we can’t reproduce this.

I can confirm that I never had this issue before upgrading to SDK 39 today. As soon as I try to send an image to my server (only tested in simulator right now) I am getting this error, too. People on SO suggest that this error happens when you update the state in the same time when you try to upload but I haven’t verified this yet - doesn’t sound right to me. Might be worth noting I am using form-data and axios.

@notbrent it looks like the image is missing. I am using ImageManipulator.manipulateAsync.

The result.uri I am getting is “file:///Users/hirbod/Library/Developer/CoreSimulator/Devices/Devices/BF07D092-9326-44E1-8128-97DD6560614F/data/Containers/Data/Application/63D2ADB5-7A71-445B-8C14-9C147C5EFA2F/Library/Caches/ExponentExperienceData/%2540hirbod%252Fmeineapp/ImageManipulator/A7AE9A34-102B-4716-A7CE-67B05DDCBE28.jpg”. It used to be a ph:// file path on iOS. Now it is a file://.

The file result returned is not existing. Before (Expo 35-38) this was working perfectly, I had to remove ph:// but that was working fine. Now the return has changed and there is no image.

If you watch the path I pasted, it looks like it is doing something weird here: %2540hirbod%252Fmeineapp

@hirbod

if you can share a minimal reproducible example (including an image that you have tried to upload that fails) where all we need to do is plug in a signed s3 url that would be helpful. please post it as an issue to https://github.com/expo/expo/issues

if this isn’t about uploading but some other issue then please share a minimal example and create an issue on https://github.com/expo/expo/issues

more info: https://stackoverflow.com/help/mcve

Hi @all, I’m facing the issue, any idea for this

It is about upload @brent. Looks like the file pointer is broken and therefore producing the error. Every other form-data request works fine.

Since every image upload on my app goes through imageManipulator, uploading on iOS is broken.

To all the other guys here: issue also happening for you with ImageManipulator “result.uri”?

Same issue here, Im using import * as ImagePicker from 'expo-image-picker';

1 Like

This is a react native issue at all, @notbrent.

https://github.com/facebook/react-native/issues/29364

The only way to fix it quickly is to upload with FileSystem.upload instead of fetch (axios build on top of that, that’s why it’s breaking there too).

I don’t know if expo can backport / cherry pick the PR and quickly help us out here

Have just submitted: https://github.com/expo/expo/issues/10317

The PR which fixes this issue is here:

Since it’s in native land, we can’t use patch package to fix anything here without a SDK Bugfix release