Your workflow is unique 👨‍💻 -  tell us how you use Dropbox here.

Forum Discussion

Alexander K.28's avatar
Alexander K.28
Helpful | Level 5
9 years ago

Is it possible to pass all parameters to a v2 API request in URL parameters?

   I have very particular situation when I cannot use request header at all and I'm basically need to pass all the parameters as URL parameters. It is not a problem for the v1 API. For example with this request I can easily upload a file

https://content.dropboxapi.com/1/files_put/auto{WorkingPathName}?access_token={AuthorizationToken}

   However it does not seem to be possible with v2 API. Specification says "These endpoints accept file content in the request body, so their arguments are instead passed as JSON in the Dropbox-API-Arg request header or arg URL parameter", So there seems to be hope it should work but it either does not accept parameters in URL or access_token parameters is not accepted.

   If it is actually possible could somebody give an example how to correctly compose a request for 'https://content.dropboxapi.com/2/files/upload'?

   I tried something like this and that did not work.

https://content.dropboxapi.com/2/files/upload?path={WorkingPathName}&access_token={AuthorizationToken}

 

5 Replies

  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Community Moderator rankDropbox Community Moderator
    9 years ago

    Hi Alexander, yes, you can pass the arguments on the URL. You cited the right documentation, but your implementation isn't quite right. You should put all of the arguments as JSON in a URL parameter actually named "arg". Likewise, you need to use the "authorization" parameter to send up the access token.

    To make the arg value, generate a JSON string of the parameters, encode as UTF-8, then use the “application/x-www-form-urlencoded” rules to encode the value.

    Here's an example using curl to upload a local test.txt file to /test.txt in Dropbox, passing authorization and arg as URL parameters:

    curl -X POST "https://content.dropboxapi.com/2/files/upload?authorization=Bearer%20ACCESS_TOKEN_HERE&arg=%7B%22path%22%3A%20%22%2Ftest.txt%22%7D" \
    --header "Content-Type: application/octet-stream" \
    --data-binary @test.txt

    The Content-Type does need to be set correctly though. I don't know what your particular situation is, but hopefully that does get set for you, or you have a way to do so.

  • Fernando M.9's avatar
    Fernando M.9
    New member | Level 1
    9 years ago
    Please , how would you to perform the download: https://content.dropboxapi.com/2/files/download
  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Community Moderator rankDropbox Community Moderator
    9 years ago

    Hi Fernando, downloading would look like:

    curl "https://content.dropboxapi.com/2/files/download?authorization=Bearer%20ACCESS_TOKEN_HERE&arg=%7B%22path%22%3A%20%22%2Ftest.txt%22%7D"
  • incode4it's avatar
    incode4it
    New member | Level 2
    8 years ago

    Why i'm getting this error ? "Error in call to API function "users/get_current_account": Invalid authorization value in URL parameter "authorization": "Bearer%20REDACTED_ACCESS_TOKEN".  Expecting "Bearer <oauth2-access-token>"." 

  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Community Moderator rankDropbox Community Moderator
    8 years ago

    incode4it That value looks right. Can you share your code, or the full/raw request and response? Just be sure to redact the access token itself.

     

    By the way, I redacted your access token from your post, but for the sake of security, you should disable that access token since you posted it publicly. You can do so by revoking access to the app entirely, if the access token is for your account, here:

     

    https://www.dropbox.com/account/security

     

    Or, you can disable just this access token using the API:


    v2: https://www.dropbox.com/developers/documentation/http/documentation#auth-token-revoke

     

About Dropbox API Support and Feedback

Node avatar for Dropbox API Support and Feedback
Get help with the Dropbox API from fellow developers and experts.

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!