Need to see if your shared folder is taking up space on your dropbox 👨‍💻? Find out how to check here.

Forum Discussion

Shwetank S.'s avatar
Shwetank S.
New member | Level 1
10 years ago

HTTP request to dropbox APIs

how do we make HTTP requests to dropbox APIs?

3 Replies

Replies have been turned off for this discussion
  • Shwetank S.'s avatar
    Shwetank S.
    New member | Level 1
    10 years ago

    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-DB's avatar
    Greg-DB
    Icon for Dropbox Community Moderator rankDropbox Community Moderator
    10 years ago

    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

Node avatar for 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!