You need to sign in to do that
Don't have an account?
Http rest callout 401 error
Hi,
While calling out other system's webservices from salesforce org. This 401 invalid seesion id error is being prompted. Even though i had mentioned Username and password in header of HttpRequest. Is there any workaround to fix it.
Code snippet has been attached below.
Http h = new Http();
Httprequest request = new Httprequest();
request.setEndpoint('https://ap2.salesforce.com/services/apexrest/Accounts/0012800000XNqPO/contacts');
request.setMethod('GET');
String username = 'xxxxx';
String password = 'xxxx';
Blob headerValue = Blob.valueOf(username + ':' + password);
String authorizationHeader = 'Basic ' + EncodingUtil.base64Encode(headerValue);
request.setHeader('Authorization', authorizationHeader);
Httpresponse response = h.send(request);
System.debug(response.getBody());
Any help, would be appreciate.
Thanks,
Abhi
http://www.jitendrazaa.com/blog/salesforce/salesforce-to-salesforce-integration-using-named-credentials-in-just-5-lines-of-code/
Can you please check by appending the security token with password and send the request.
Thanks