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: 

Upload a file via wininet with a POST

Upload a file via wininet with a POST

jmsalvador
Explorer | Level 3

Hi Team,

we are using the Dropbox REST API with OAuth2.
When attempting to upload a file I don't know where to put the file contents using the wininet for http way.

 

In the docs there is just a curl example

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

but I don't understand how to put the contents file.

I see the 3 headers like in the example but what about the file ?.

data-binary is put in the body ?

or in the header ?

and how ?

I used the postman tool to reproduce the upload I was successful. The problem is that the postman put the file in the body in a binary way selecting the file with a explorer but I cannot see how and where to put it using HttpSendRequest with a POST verb.

 

Any suggestion to do it ?

Thanks in advance

 

1 Reply 1

Greg-DB
Dropbox Staff

The /2/files/upload endpoint is a "content-upload" style endpoint, so it does expect the file data for the upload in the request body. That is what curl's "--data-binary" does. (I.e., in the example, that's how you specify what data or file curl should use for the request body.)

 

I can't offer support for and don't have a sample for WinINet/HttpSendRequest specifically unfortunately though, so you'll need to refer to the documentation for that for instructions on how to configure a request using that with the desired data in the body.

Need more support?
Who's talking

Top contributors to this post

  • User avatar
    Greg-DB Dropbox Staff
What do Dropbox user levels mean?