You need to sign in to do that
Don't have an account?
Not able to authorizae a https site using HttpRequest
Hello Friends,
I am not able to authorization error,when i do a rest call using the HttpRequest .should i use certificate,if so how do i handle it through coding
here is my cod example
public void basicAuthCallout(){HttpRequest req = new HttpRequest();
req.setEndpoint(url);
req.setMethod('POST');
String username = username;
String password = password;
String const_data = '<?xml version="1.0" encoding="UTF-8"?><activity name="New activity via salesforce"></activity>';
Blob headerValue = Blob.valueOf(username + ':' + password);
String authorizationHeader = 'BASIC ' +EncodingUtil.base64Encode(headerValue);
req.setHeader('Authorization', authorizationHeader);
req.setHeader('Accept', 'application/xml');
req.setBody(const_data);
// Create a new http object to send the request object
// A response object is generated as a result of the request
Http http = new Http();
HTTPResponse res = http.send(req);
res = http.send(req);
System.debug(res.getBody());
}
All Answers