Newer Version Available
Custom Headers and Bodies of Apex Callouts That Use Named Credentials
Salesforce generates a standard authorization header for each callout to a
named-credential-defined endpoint, but you can disable this option. Your Apex code can also use
merge fields to construct each callout’s HTTP header and body.
This flexibility enables you to use named credentials in special situations. For example, some remote endpoints require security tokens or encrypted credentials in request headers. Some remote endpoints expect usernames and passwords in XML or JSON message bodies. Customize the callout headers and bodies as needed.
The Salesforce admin must set up the named credential to allow Apex code to construct headers or use merge fields in HTTP headers or bodies. The following table describes these callout options for the named credential.