Loading

Named Credentials causing System.UnexpectedException: Script-thrown exception on HTTP callout error

Publish Date: Oct 13, 2022
Description
Users can find the errors with HTTP callouts when involving named credentials, and can see the error message System.UnexpectedException: Script-thrown exception on HTTP callout
Resolution

There could be multiple reasons for the above error message. Before raising a case with support, it would be best to re-verify the below steps to debug further. 

 
  1. Verify if the callout name used in Apex Methods matches the Named Credential’s API name under Setup-> Named Credentials. 

If there is a mis-match, kindly make sure to change and use the same syntax/api name of the Named Credentials.
Ref:  Named Credentials as Callout Endpoints

 
  1. Verify if the URL has any path that needs to escape URL reserved characters 
 
  1. Verify if the remote endpoint has any stricter URL path filtering that may have been enabled. Example: Replacing “\” with “%5c”This is controlled at the endpoint level and not at salesforce.


Additional ResourceTest classes fail with error 'System.SObjectException: Script-thrown exception'

Knowledge Article Number

000392650

 
Loading
Salesforce Help | Article