cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Want to learn some quick and useful tips to make your day easier? Check out how Calvin uses Replay to get feedback from other teams at Dropbox here.

Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Api v2 upload document wrong

Api v2 upload document wrong

Trương K.
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

Greg-DB
Dropbox Staff

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

Trương K.
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

Steve M.
Dropbox Staff

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

Trương K.
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

 

Steve M.
Dropbox Staff

I'm having trouble following this thread.

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

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

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

Greg-DB
Dropbox Staff

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! 

hinto
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

Greg-DB
Dropbox Staff
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
Need more support?
Who's talking

Top contributors to this post

  • User avatar
    Greg-DB Dropbox Staff
  • User avatar
    iosenqa Explorer | Level 4
  • User avatar
    aaqrabaw New member | Level 2
What do Dropbox user levels mean?