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
Gourav Kumar ChakrabortyGourav Kumar Chakraborty 

Registering external services in salesforce

Hi All,
 
I have a requirement wherein I have to set up an external service via configuration and use flows to call the service methods. This works fine for services without any authentication parameters, however I am facing issues to register the service when there are authentication parameters involved.
The parameters for my services are :
 
X-Api-Key *
string (header) : API Key provided by Integration team per environment
Authorization *
string (header) : Auth Token
JWToken *
string (header) : JWT Token - Send this token only for OpenID
expirein *
string (header) : expire in time field
Content-Type *
string (header) : application/json
 
These are required parameters. When I try to register the service i get an error : "Your schema can't be parsed. Check the schema parameters."
 
The documentation (https://help.salesforce.com/articleView?id=external_services_register.htm&type=5) says that X-Api-Key can be passed in parameters in the named credentials, I tried the same and it did not work out.
 
Any help on how I can pass these parameters while registering the external service in salesforce would be really appreciated.
Raj VakatiRaj Vakati
Refer this linnk

https://trailhead.salesforce.com/en/content/learn/modules/external-services/define-a-schema-for-an-external-service
https://trailhead.salesforce.com/en/content/learn/modules/external-services/register-an-external-service
Krishna Sandeep 4Krishna Sandeep 4
I was also facing same issue . can anyone achieved sending api key in headers using external services.
Steve Pendleton 41Steve Pendleton 41
I have also been trying to pass an API-Key as a form of authentication using external services/named credetials. My many hours of research show that the only way you can currently use an API-Key for authentication in external services is when the api endpoint can receive the API-key as a URL parameter. Since some APIs only accept API-Keys via the header, this is a problem as passing the API-Key via the header using external services doesn't seem to be supported by Salesforce at this time! This Salesforce page confirms header parameters are not supported: https://help.salesforce.com/articleView?id=external_services_schema.htm&type=5. I did try to add a header value in the schema definition using the 'default' property but couldn't get it to work. I think Salesforce ignores/doesn't use any header parameter stuff at all.  If anyone knows of a way to customize the callout header so it can be passed using external services via a flow, you get bonus points :)!
Maarten LapereMaarten Lapere
@Steve it seems that headers are supported by Enhanced External Services:

https://help.salesforce.com/articleView?id=enhanced_external_services.htm&type=5

"Enhanced External Services is an improved way to connect to outside services. New registrations can handle more-complex OpenAPI 2.0 schema, nested object types and send parameters as headers within the HTTP requests. They are not subject to Apex word and character limitations. New registrations can continue to benefit from other capabilities as they become available."
Rene Grohmann 2Rene Grohmann 2
Hi, I had the same challenge today and was able to solve this as follows:
  • Extend Header parameter within the OpenAPI/Swagger spec
  • Add the APIKEY value to the Flow action
User-added image