I have a callout where we use a Named Credential
and it looks something like the following:
public class MyClass
{
public MyClass()
{
inputHttpHeaders_x = new Map<String, String>
{
'Authorization' => 'Basic {!$Credential.AuthorizationHeaderValue}'
};
}
public SomeType makeCallout(/*parameters*/)
{
WebServiceCallout.invoke(
this,
request_x,
response_map_x,
new String[]{
'callout:My_Credential'
// other parameters
}
);
}
}
Notice I am using an endpoint of callout:My_Credential
and using $Credential.AuthorizationHeaderValue
in my Authorization
header.
This callout worked great in the development sandbox. When we deployed it to UAT along with the Named Credential
, however, it didn't work. We were getting a 401 response. I changed the header to hard code the token and the callout worked, so it looked like a password issue. I edited the Named Credential
record to reset the password to exactly what it was in the development environment, and the problem was resolved.
Do Named Credential
records deploy without Password
being populated? Or does the $Credential.AuthorizationHeaderValue
just not get carried through? Is it possible to deploy a credential with either of these values intact?