function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
pragya Mishra 41pragya Mishra 41 

Facing issues while using Password as an authentication Protocol in “Named Credentials ” salesforce?

I am using Named Credential as an Identity Type and Password Authentication as an Authentication Protocol 
I have checked all three check boxes:
Generate Authorization Header.
Allow Merge Fields in HTTP Header.
Allow Merge Fields in HTTP Body.
While I am trying to execute below code,facing issues:

HttpRequest req = new HttpRequest(); req.setEndpoint('callout:HTTP_Basic_Credential/services/data/v32.0');
req.setMethod('GET');
//sending request

HTTP_Basic_Credential is a name of mine Named Credential.

While  I am setting Generate Authorization Header flag , I am receving below error:

[{"message":"INVALID_HEADER_TYPE","errorCode":"INVALID_AUTH_HEADER"}]

If flag is not set then getting :Session is expired.

 
Niks DeveloperNiks Developer
Salesforce as a provider does not support Password Authentication. Check this for more information:
https://niksdeveloper.com/salesforce/named-credentials-in-salesforce-with-example/