cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
What’s new: end-to-end encryption, Replay and Dash updates. Find out more about these updates, new features and more 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 File Api

Upload File Api

Fab_R
Explorer | Level 3
Go to solution

Hey guys,

 

I'm getting a pdf content and want to upload it in my dropbox with the API.

 

When i'm sending the request with the /upload method, i'm getting no response from dropbox ...

 

Can you please help on that ?

 

Here is my code :

 

        HttpRequest req = new HttpRequest();
        req.setEndpoint('https://content.dropboxapi.com/2/files/upload');
        req.setHeader('Authorization','Bearer ' + token);
        req.setHeader('Dropbox-API-Arg','{\"path\": \"/Liasses/Test.txt\",\"mode\": \"add\",\"autorename\":false}');
        req.setHeader('Content-Type','application/octet-stream');
        req.setMethod('POST');
        req.setBody(EncodingUtil.base64Encode(blobToEncode));
        
        req.setTimeout(60000);
        
        Http h = new http();
        HttpResponse res = new HttpResponse();
        string resp = res.getBody();
        
        system.debug('response : ' + resp);

 

 

 

Thanks in advance !

1 Accepted Solution

Accepted Solutions

Greg-DB
Dropbox Staff
Go to solution
It looks like you're using a third party HTTP client, and not one of our official SDKs, so we can't offer help with how to construct the call with your client.

That said, looking at your code, you don't appear to actually be using your `req` object. You probably need something like `HTTPResponse res = h.send(req);`. I recommend referring to the documentation for this HTTP client for information on how to make requests.

View solution in original post

1 Reply 1

Greg-DB
Dropbox Staff
Go to solution
It looks like you're using a third party HTTP client, and not one of our official SDKs, so we can't offer help with how to construct the call with your client.

That said, looking at your code, you don't appear to actually be using your `req` object. You probably need something like `HTTPResponse res = h.send(req);`. I recommend referring to the documentation for this HTTP client for information on how to make requests.
Need more support?
Who's talking

Top contributors to this post

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