We Want to Hear From You! What Do You Want to See on the Community? Tell us here!
Forum Discussion
BiswojeetRay
7 years agoNew member | Level 2
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();
1 Reply
- TaylorKrusen7 years ago
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.
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.6,036 PostsLatest Activity: 12 hours ago
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 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!