Closed
Description
Description
I'm trying to use the Dropbox API with React-Native but when I try to call filesUpload I'm getting the following error:
Error in call to API function "files/upload": Bad HTTP "Content-Type" header: "application/octet-stream; charset=utf-8". Expecting one of "application/octet-stream", "text/plain; charset=dropbox-cors-hack".
The Dropbox SDK makes use of the superagent library and it sets up the call like this:
apiRequest = request.post(getBaseURL(host) + path)
.type('application/octet-stream')
.set('Authorization', 'Bearer ' + accessToken)
.set('Dropbox-API-Arg', httpHeaderSafeJson(args));
So the content-type is set to just "application/octet-stream" but when the request is eventually executed it's changed to "application/octet-stream; charset=utf-8". I'm assuming the SDK works fine in Node or in a browser, and that it's something that React-Native is adding. Is it a known issue? Is there any way to go around it?
Solution
Make sure that HTTP calls coming from React-Native do not append ; charset=utf-8
to the Content-Type (or make it optional).
Additional Information
- React Native version: 0.44
- Platform: Android (running on emulator under Windows)
- Development Operating System: Windows 10
- Dev tools: Android Studio