Skip to main content
Abhishek Kandukuri a posé une question dans #Security
Hi,

I'm trying to access Named Credentials to send a HttpRequest in my apex code and I'm getting the following error:

15:41:55:098 EXCEPTION_THROWN [32]|System.CalloutException: We couldn't access the credential(s). You might not have the required permissions, or the external credential "test_external_cred" might not exist.

My Name Credentials have an External Credetial called "test_external_cred" for Authentication.  Please suggest a way to resolve this.
5 réponses
  1. 30 oct., 15:02

    Adding to Juan's answer, because principal access alone wasn't enough when we tested it. Full write-up with the round-by-round results: 

     

    https://revecast.io/resources/salesforce-how-to/salesforce-named-credential-couldnt-access-credentials/?utm_source=trailblazer&utm_medium=community&utm_campaign=guides-2026-q4&utm_content=named-credential-access

     

     

    The user running your Apex needs both of these, ideally in one permission set: 

     

    1. External Credential Principal Access → Edit → add the principal from test_external_cred (create one under Principals first if it has none, as Juan says). 

    2. Object Settings → User External Credentials → Read. 

    3. Assign it to the user the code actually runs as. If it works in Execute Anonymous but not elsewhere, the code is running as someone else: another user, the Automated Process user for platform event triggers, or whoever scheduled the job. 

     

    In our test, a standard user with only step 1 still failed, with a new error: "You don't have read permissions on the User External Credential object." With both steps it returned HTTP 200. 

     

    We ran it in a Salesforce org with Revecast Orchestrate. The guide also has a small Apex snippet that logs exactly which permission is missing.