cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
We recently received a question asking for advice on how to set up a Dropbox account for an elderly family member. This prompted us to think about the different ways we can make Dropbox more accessible in general, learn about it and add your tips right over 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: 
1
Ask
2
Reply and help

HTTP request to dropbox APIs

HTTP request to dropbox APIs

Shwetank S.
New member | Level 1

how do we make HTTP requests to dropbox APIs?

3 Replies 3

Re: HTTP request to dropbox APIs

Greg-DB
Dropboxer

We recommend using one of the official SDKs, if possible:

https://www.dropbox.com/developers

Those will handle the work of making the HTTPS calls for you.

Otherwise, you can use your own HTTPS client (whatever that may be for for whatever platform you're using) to connect to the HTTPS endpoints directly:

https://www.dropbox.com/developers/documentation/http/documentation

Re: HTTP request to dropbox APIs

Shwetank S.
New member | Level 1

I prefer to use HTTP endpoints for now. 

Is there any code snippets which depicts below way of communicating with dropbox APIs via HTTP(javascript) route

- Authorize and get access token

- call dropbox APIs using access token 

Re: HTTP request to dropbox APIs

Greg-DB
Dropboxer

The app authorization process is handled via OAuth 2. The documentation for the OAuth 2 page and endpoint can be found here:

https://www.dropbox.com/developers/documentation/http/documentation#oauth2-authorize

There's a blog post here that shows how to implement OAuth 2:

https://blogs.dropbox.com/developers/2013/07/using-oauth-2-0-with-the-core-api/

There's also an OAuth guide here that may be helpful:

https://www.dropbox.com/developers/reference/oauthguide

And here's a simple example of uploading a file (from text) in JavaScript using jQuery:

 var data = new TextEncoder("utf-8").encode("Test");
$.ajax({
url: 'https://content.dropboxapi.com/2/files/upload',
type: 'post',
data: data,
processData: false,
contentType: 'application/octet-stream',
headers: {
"Authorization": "Bearer <ACCESS_TOKEN>",
"Dropbox-API-Arg": '{"path": "/test_upload.txt","mode": "add","autorename": true,"mute": false}'
},
success: function (data) {
console.log(data);
}
})

<ACCESS_TOKEN> should be replaced with the OAuth 2 access token.

And here's a simple example of getting the user's account information using jQuery:

 jQuery.ajax({
url: 'https://api.dropboxapi.com/2/users/get_current_account',
type: 'POST',
headers: {
"Authorization": "Bearer <ACCESS_TOKEN>"
},
success: function (data) {
console.log(data);
},
error: function (error) {
console.log(error);
}
})

<ACCESS_TOKEN> should be replaced with the OAuth 2 access token.
Who's talking

Top contributors to this post

  • User avatar
    Greg-DB Dropboxer
  • User avatar
    Shwetank S. New member | Level 1
What do Dropbox user levels mean?
Need more support?