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-accessThe 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.
5 件の回答