1

Making a callout with new Named Credentials + External Credentials gives an error

System.CalloutException: We couldn't access the credential(s). You might not have the required permissions, or the external credential "asdf2" might not exist.

Have anyone configured new Named Credentails with External Credentials? My goal was to copy existing Named Credential (legacy). The code I'm trying to execute is the same as with legacy Named Credentials. The only difference is the name. The legacy has 'asdf' as name, the new one - 'asdf2'. The External Credential has the same 'asdf2' name.

HttpRequest tmpRequest = new HttpRequest();
tmpRequest.setEndpoint('callout:asdf/service/heartbeat');
tmpRequest.setMethod('GET');
HttpResponse response = new Http().send(tmpRequest);
system.debug(response);
3
  • Does the current user have access to "User External Credentials" object ? Please check if this link helps - infallibletechie.com/2022/03/…
    – Rohit
    Mar 22, 2023 at 8:05
  • It has Modify All permission. I'm using a User with standard System Admin profile. Interestingly, I don't see it among objects I'm able to SOQL. Mar 22, 2023 at 8:18
  • The answer is to have External Credential assigned to a Permission Set AND Authenticate it. Under actions for a Permission Set Mappings on an External Credential there is an option - Authenticate. Once that is clicked and the Authentication Status became Configured everything started working. Thanks to salesforce.stackexchange.com/a/392112/673 Mar 22, 2023 at 8:31

0

Browse other questions tagged .