Aug 20 2017
11:59 PM
- last edited on
Jul 31 2018
12:02 PM
by
TechCommunityAP
Aug 20 2017
11:59 PM
- last edited on
Jul 31 2018
12:02 PM
by
TechCommunityAP
We are making an rest request service call from salesforce, but we are failing the authentication process,
below is the sample code which we have tried but we are getting this error " RESPONSE STRING: System.HttpResponse[Status=Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature., StatusCode=403]"
From the Below code:
public class UploadFileInAzure{
public static void UploadFile(){
//Request
HttpRequest req = new HttpRequest();
req.setEndpoint('http://salesforcestrongaccount.file.core.windows.net/atif321/WO#-001?restype=directory');
req.setMethod('PUT');
req.setHeader('x-ms-version', '2017-04-17');
req.setHeader('x-ms-date','Mon, 27 Jan 2014 22:50:32 GMT');
req.setHeader('x-ms-meta-Category','images');
req.setHeader('Authorization','salesforcestrongaccount 9Mz2V95s364Rh4FuaNfc0bd5uY3XIVtRGt99wmPuU2uIyiOdNvzbGnh70MLyEc4dCniwC+nJV8BvF9sbifQHJQ==');
req.setHeader('Content-Length','512');
system.debug(req);
//Response
Http http = new Http();
HTTPResponse res = http.send(req);
System.debug('MYDEBUG: ' + ' RESPONSE STRING: ' + res.toString());
System.debug('MYDEBUG: ' + ' RESPONSE STATUS: '+res.getStatus());
System.debug('MYDEBUG: ' + ' STATUS_CODE:'+res.getStatusCode());
System.debug('MYDEBUG: ' + ' STATUS_CODE:'+res.getBody());
}
}