cancel
Showing results for 
Search instead for 
Did you mean: 
Announcements
Update: Find information on Dropbox support during COVID-19 here
Close
cancel
Showing results for 
Search instead for 
Did you mean: 

Api v2 upload document wrong

Trương K. New member | Level 1
New member | Level 1

an wrong in dropbox api v2 document

curl -X POST https://content.dropboxapi.com/2/files/upload \
    --header "Authorization: Bearer " \
    --header "Dropbox-API-Arg: {\"path\": \"/Homework/math/Matrices.txt\",\"mode\": \"add\",\"autorename\": true,\"mute\": false}" \
    --header "Content-Type: application/octet-stream" \
    --data-binary @local_file.png

when i set header
--header "Content-Type: application/octet-stream" \

=> can't send/ return error 

but when i remove that header and add 

--header "Content-Type: text/plain; charset=dropbox-cors-hack" \

=> return 200, succeed,
recheck: file was upload successful


13 Replies 13

Re: Api v2 upload document wrong

Dropboxer
Dropboxer

When you say you "can't send/ return error", what's the error you get exactly?

Re: Api v2 upload document wrong

Trương K. New member | Level 1
New member | Level 1

Content-Type: application/octet-stream

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

Error:400"

 

It seems that orther dev of dropbox fix it? (Edit: i think my code error when not send data in binary)
at that time the error return say
Expecting one of "application/octet-stream", "text/plain; charset=utf-8"

and when add two header 
Content-Type: application/octet-stream (1)
Content-Type: text/plain; charset=dropbox-cors-hack (2)
=> return error

add only (1) or (2) => return success

Re: Api v2 upload document wrong

Dropboxer
Dropboxer

Are you by any chance making an AJAX request and using Firefox?

There seems to be a known issue with Firefox where it adds the "charset=UTF-8".

Re: Api v2 upload document wrong

Trương K. New member | Level 1
New member | Level 1

Sorry, i think my code error when not read file in binary mode

-> server think a text -> return error utf-8

 

Re: Api v2 upload document wrong

Dropboxer
Dropboxer

I'm having trouble following this thread.

Is your issue resolved? Or are you still having a problem?

Re: Api v2 upload document wrong

Fernando M.9 New member | Level 1
New member | Level 1
I'm getting the same error message

Expecting one of "application/octet-stream", "text/plain; charset=dropbox-cors-hack".

Re: Api v2 upload document wrong

Dropboxer
Dropboxer

Fernando, can you start a new thread with the specific code you're having trouble with? That way we can help you in particular without spamming the others on this thread.

https://www.dropboxforum.com/hc/en-us/community/posts/new?community_post%5Btopic_id%5D=200209245

Thanks in advance! 

Re: Api v2 upload document wrong

hinto New member | Level 2
New member | Level 2
Was there a resolution to this? It looks like there's only 2 content-types I can send via the upload endpoint

Re: Api v2 upload document wrong

Dropboxer
Dropboxer
Hi Hinto, we haven't heard back from Trương on this thread, so we don't know if their issue was resolved.

Fernando opened a thread here:

https://www.dropboxforum.com/t5/API-support/Is-it-possible-to-pass-all-parameters-to-a-v2-API-reques...

If neither of these help in your case, please open a new thread with the details of the issue you're having so we can help:

https://www.dropboxforum.com/t5/forums/postpage/board-id/101000014

Work Smarter with Dropbox

The way we work is changing. Share and discover new ways to work smarter with Dropbox in our community.

Sound good? Let's get started.
Who's talking

Top contributors to this post

What do Dropbox user levels mean?
Need more support?