You might see that the Dropbox Community team have been busy working on some major updates to the Community itself! So, here is some info on what’s changed, what’s staying the same and what you can expect from the Dropbox Community overall.

Forum Discussion

BiswojeetRay's avatar
BiswojeetRay
New member | Level 2
6 years ago

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

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();



  • 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.

     

     

About Dropbox API Support & Feedback

Node avatar for Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.5,918 PostsLatest Activity: 2 days ago
334 Following

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 or Facebook.

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!