cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Want to know what we learned at IBC? Check out our learnings on media, remote working and more right 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: 

I am getting error when i am trying to upload file from salesforce.

I am getting error when i am trying to upload file from salesforce.

BiswojeetRay
New member | Level 2

I am integrating salesforce with Dropbox.
But when i am trying to hit the api it showing error.

Error - 

HTTP header "Dropbox-API-Arg": could not decode input as JSON

Code - 
string token = 'https://content.dropboxapi.com/2/files/upload';
HttpRequest r = new HttpRequest();
r.setEndpoint(token);
r.setHeader('Authorization','Bearer ' +accesstoken);
r.setheader('content-type','application/octet-stream');
r.setheader('Dropbox-API-Arg', JSON.stringify({\'path\': response.data.entries[i].id}));
r.setMethod('POST');
r.setTimeout(60000);*/
Attachment at = [ SELECT Name, body
FROM Attachment
LIMIT 1];
//here we input file as blob for save in DROP BOX
r.setBodyAsBlob(at.body);
Http h1 = new Http();
HttpResponse res1;
string resp1;
res1 = h1.send(r);
resp1 = res1.getBody();



1 Reply 1

TaylorKrusen
Dropbox Staff

Hello,

You're writing this in Apex, correct? 

That error means that the value being sent back with the "Dropbox-API-Arg" header isn't valid JSON. 

The `JSON.Stringify()` method you're using doesn't exist in all languages. Instead, Apex has a method called `JSON.Serialize()`. You can read about it here

Try changing the method and see if that helps.

 

 

Need more support?
Who's talking

Top contributors to this post

  • User avatar
    TaylorKrusen Dropbox Staff
What do Dropbox user levels mean?