Hello,
I have chained to 2 proxies using ServiceCallout. The first proxy uses API key validation and the API key is passed in the header variable "x-apikey". Could someone help me on how to send the same API key in the header of the ServiceCallout policy?
The below one is not working:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ServiceCallout continueOnError="false" enabled="true" name="Service-Callout-1">
<DisplayName>Service Callout-1</DisplayName>
<Properties/>
<Request clearPayload="true" variable="myRequest">
<Set>
<Verb>GET</Verb>
<Headers>
<Header name="x-apikey">{request.header.x-apikey}</Header>
</Headers>
</Set>
</Request>
<Response>calloutResponse</Response>
<LocalTargetConnection>
<Path>/XXX/healthcheck</Path>
</LocalTargetConnection>
</ServiceCallout>
Checkout the docs page. You can remove the "clearPayload" flag in the <Request> element or set the apikey in the ServiceCallout request as described in the docs.
Thanks
Hi,
I cleared out the "clearPayload" flag from the policy but still getting the below error:
Execution of ServiceCallout Service-Callout-1 failed. Reason: ResponseCode 401 is treated as error
Update ServiceCallout:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ServiceCallout continueOnError="false" enabled="true" name="Service-Callout-1">
<DisplayName>Service Callout-1</DisplayName>
<Properties/>
<Request variable="myRequest">
<Set>
<Verb>GET</Verb>
</Set>
</Request>
<Response>calloutResponse</Response>
<LocalTargetConnection>
<Path>/XXX/healthcheck</Path>
</LocalTargetConnection>
</ServiceCallout>
Sorry I misunderstood your question. The "clearPayload" flag is to control the Request object post ServiceCallout invocation.
I did the same policy defn, as you have mentioned, its working for me. Can you share what error you are getting when executing this proxy?