Need to see if your shared folder is taking up space on your dropbox 👨💻? Find out how to check here.
Forum Discussion
Shwetank S.
10 years agoNew member | Level 1
HTTP request to dropbox APIs
how do we make HTTP requests to dropbox APIs?
3 Replies
Replies have been turned off for this discussion
- Greg-DB10 years ago
Dropbox Community Moderator
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
- Shwetank S.10 years agoNew 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
- Greg-DB10 years ago
Dropbox Community Moderator
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.
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
The Dropbox Community team is active from Monday to Friday. We try to respond to you as soon as we can, usually within 2 hours.
If you need more help you can view your support options (expected response time for an email or ticket is 24 hours), or contact us on X, Facebook or Instagram.
For more info on available support options for your Dropbox plan, see this article.
If you found the answer to your question in this Community thread, please 'like' the post to say thanks and to let us know it was useful!