You need to sign in to do that
Don't have an account?
Dejan Cvetkoski
Upload file to dropbox with api
Anyone help me. How i can upload file to dropbox with dropbox api? Thanks
function readOnly(count){ }
You need to sign in to do that
Don't have an account?
This below code will help you
HttpRequest req = new HttpRequest();
req.setEndpoint('https://api.dropboxapi.com/2/sharing/create_shared_link_with_settings');
req.setbody('path='+path+',settings: {"requested_visibility": "public"}');
// {"path": '+path+',"settings": {"requested_visibility": "public" } }
req.setHeader('Authorization', 'Bearer ' + Label.DropboxAPI);
req.setHeader('Content-Type','application/json');
req.setMethod('POST');
req.setTimeout(60000);
Http h = new Http();
HttpResponse res = h.send(req);
string jsonResponse = res.getBody();
system.debug('Response ->' + jsonResponse);
public static String getLink(String path_lower){
HttpRequest req = new HttpRequest();
req.setEndpoint('https://api.dropboxapi.com/2/sharing/create_shared_link_with_settings');
req.setHeader('Authorization', 'Bearer JJJX68WdGNAAAAAAAAAutYW7HvDKVrbhSCiEDxEUuAitEgMIgoZWKZvrE9pI2TwB');
req.setHeader('Content-Type','application/json');
req.setbody('path='+path_lower+'Body');
String Body ='{"settings":{"requested_visibility": "public" }';
req.setMethod('POST');
req.setTimeout(60000);
Http h = new Http();
HttpResponse res = h.send(req);
string jsonResponse = res.getBody();
system.debug('Response ->' + jsonResponse);
Map<String, Object> response = (Map<String, Object>) JSON.deserializeUntyped(jsonResponse);
return (String)response.get('url');
}
I am update the dropbox api 2.0 .This code is getiing error 400 .please help me the solution.
what is the value of path in your code.
Thnaks.
This below code is working for upload file from salesforce to dropbox.
blob b = yourPdf;
Http http = new Http();
HttpRequest req = new HttpRequest();
req.setEndpoint('https://content.dropboxapi.com/2/files/upload');
req.setMethod('POST');
req.setHeader('Content-Type', 'multipart/form-data');
req.setHeader('Authorization','Bearer '+AccessToken);
req.setHeader('Content-Type', 'application/octet-stream');
req.setHeader('Dropbox-API-Arg','{"path":"folderNmae+'/'+fileName+'.pdf","mode":"add","autorename":true,"mute":false,"strict_conflict":false}');
req.setBodyAsBlob(b);
req.setTimeout(120000);
HttpResponse res = http.send(req);
https://www.codekiat.com/2019/07/salesforce-dropbox-integration-a-complete-guide.html
--
Naveen K N