I'm trying to make a callout using named Credentials and my Authentication Protocol is Password Authentication. But I'm getting Unauthorized status. I'm not sure if I'm missing any parameter or something else

System.HttpResponse[Status=Unauthorized, StatusCode=401]

below is my code:

HttpRequest req = new HttpRequest();
Http http = new Http();
HTTPResponse res = http.send(req);
System.debug('>>> res... '+res.getBody());

Does the endpoint you're trying support "Basic Authentication"? If not, you can't use Password Authentication. Please consult the documentation for the endpoint you're calling to see if this is even supported. For example, if you're trying to connect to another Salesforce org, you need to use OAuth instead.

  • so my approach is correct, I need to check if it supports basic authentication – salesforce Developer Oct 30 '19 at 13:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.