When we perform a retry using the ServiceCallout policy and receive a response with status code 400 or 401 from the Target endpoint, the retry is triggered. However, during the second attempt, it fails because we are not able to read the header value below adding the code please have a look
ServiceCallout Policy
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ServiceCallout async="false" continueOnError="true" enabled="true" name="SC-RetryProxyLoopback">
<DisplayName>SC-RetryProxyLoopback</DisplayName>
<Properties/>
<Request clearPayload="false">
<Set>
<Verb>{request.verb}</Verb>
<Path>{proxy.pathsuffix}</Path>
<Headers>
<!-- Use dynamic header based on response code -->
<Header name="X-IntelligentComplianceKey">{retry.header.X-IntelligentComplianceKey}</Header>
<Header name="Authorization">{retry.header.Authorization}</Header>
<Header name="Content-Type">{request.header.Content-Type}</Header>
<Header name="X-Retry-Attempt">1</Header>
</Headers>
<Payload contentType="{request.header.Content-Type}">{request.content}</Payload>
<QueryParams>{request.queryparams}</QueryParams>
</Set>
</Request>
<Response>calloutResponse</Response>
<HTTPTargetConnection>
<URL>https://example.com</URL>
</HTTPTargetConnection>
</ServiceCallout>
and Target EndPoint
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<TargetEndpoint name="checkCompliance">
<Description/>
<FaultRules>
<FaultRules>
<FaultRule name="HeaderValidationError">
<Condition>(headers.valid = false) or (headers.error != null) or (auth.invalid.format = true)</Condition>
<Step>
<Name>AM-HandleHeaderError</Name>
</Step>
</FaultRule>
</FaultRules>
<FaultRule name="RetryError">
<FaultRule name="RetryError">
<Condition>(retry.error != null) or (servicecallout.SC-RetryProxyLoopback.failed = true)</Condition>
<Step>
<Name>AM-HandleRetryError</Name>
</Step>
</FaultRule>
</FaultRule>
</FaultRules>
<PreFlow name="PreFlow">
<Request>
<Step>
<Name>Compliance-Target-Path</Name>
</Step>
</Request>
<Response/>
</PreFlow>
<PostFlow name="PostFlow">
<Request/>
<Response>
<!-- Validate headers first -->
<Step>
<Condition>response.status.code = "401"</Condition>
<Name>JS-HeaderValidator</Name>
</Step>
<!-- Handle retry if headers are valid -->
<Step>
<Condition>headers.valid = true and response.status.code = "401"</Condition>
<Name>JS-RetryHandle</Name>
</Step>
<!-- Get new token if retry needed -->
<Step>
<Condition>shouldRetry = true</Condition>
<Name>KVM-PRG_detail</Name>
</Step>
<!-- Make retry request -->
<!-- <Step>
<Condition>shouldRetry = true</Condition>
<Name>SC-RetryProxyLoopback</Name>
</Step>-->
<!-- Handle response -->
<Step>
<Name>AM-HandleRetryResponse</Name>
<Condition>calloutResponse != null</Condition>
</Step>
</Response>
</PostFlow>
<HTTPTargetConnection>
<URL>https://example.com</URL>
<Properties>
<Property name="response.streaming.enabled">true</Property>
<Property name="request.streaming.enabled">true</Property>
<Property name="supports.http10">true</Property>
</Properties>
</HTTPTargetConnection>
</TargetEndpoint>
Hi @Garima96 ,
It looks like during the retry, the dynamic headers like {retry.header.X-IntelligentComplianceKey} and {retry.header.Authorization} are missing or not set correctly in the second call.
Hereโs what you can check:
-Ensure the headers are saved from the first response into flow variables before the retry. For example, extract Authorization from the 401 response and store it in a variable like retry.header.Authorization.
-Before calling SC-RetryProxyLoopback, confirm that these variables are correctly populated โ otherwise, the retry will fail.
-You may need a JavaScript or AssignMessage step after the first call to copy these headers into the right variables for retry.
User | Count |
---|---|
1 | |
1 | |
1 | |
1 | |
1 |