cancel
Showing results for 
Search instead for 
Did you mean: 
Announcements
Update: Find information on Dropbox support during COVID-19 here
Close
cancel
Showing results for 
Search instead for 
Did you mean: 

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

BiswojeetRay New member | Level 2
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

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

Dropboxer
Dropboxer

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.

 

 

Work Smarter with Dropbox

The way we work is changing. Share and discover new ways to work smarter with Dropbox in our community.

Sound good? Let's get started.
Who's talking

Top contributors to this post

What do Dropbox user levels mean?
Need more support?