Execute XSL Policy Conditionally

jjjegath
Participant II

Can we conditionally execute the policy in the APIGEE flow.Say that i have written two XSLT policy in the flow one for happy flow response and another for error flow response received from the target service. Based on response received from i need to execute either any one of the XSLT policy

Solved Solved
0 1 170
1 ACCEPTED SOLUTION

sidd-harth
Participant V

Hi @Jegath Kumar, all policies can have multiple conditional statements. Check this doc and provide your exact requirement(what kind of response) for detailed answers,

https://docs.apigee.com/api-platform/reference/conditions-reference#whereyoucanuseconditionalstateme...

<Flow name="GetRequests">
  <Condition>request.verb = "GET"</Condition>
  <Request>
    <Step>
      <Condition>request.path MatchesPath "/statuses/**"</Condition>
      <Name>StatusesRequestPolicy</Name>
    </Step>
  </Request>
  <Response>
    <Step>
      <Condition>(response.status.code = 503) or (response.status.code = 400)</Condition>
      <Name>MaintenancePolicy</Name>
    </Step>
  </Response>
</Flow>

If you see this sample xml, the MaintenancePolicy will be executed only if Status code is 400 or 503.

This policy will be skipped if status code is 200 or another.

View solution in original post

1 REPLY 1

sidd-harth
Participant V

Hi @Jegath Kumar, all policies can have multiple conditional statements. Check this doc and provide your exact requirement(what kind of response) for detailed answers,

https://docs.apigee.com/api-platform/reference/conditions-reference#whereyoucanuseconditionalstateme...

<Flow name="GetRequests">
  <Condition>request.verb = "GET"</Condition>
  <Request>
    <Step>
      <Condition>request.path MatchesPath "/statuses/**"</Condition>
      <Name>StatusesRequestPolicy</Name>
    </Step>
  </Request>
  <Response>
    <Step>
      <Condition>(response.status.code = 503) or (response.status.code = 400)</Condition>
      <Name>MaintenancePolicy</Name>
    </Step>
  </Response>
</Flow>

If you see this sample xml, the MaintenancePolicy will be executed only if Status code is 400 or 503.

This policy will be skipped if status code is 200 or another.