Keep proxy conditional flow when request variables are changed at target

I have a proxy which accepts a POST at the resource level.

However the target accepts a GET, and hence I am changing the verb using an AssignMessage policy.

The problem though is that when the request comes back from the target the proxy condition is not matching, since the request.verb is now changed from POST to GET.

I know this is an obvious use case, but I seem to be missing something. Also I don't want to over-complicate this by store variables and having multiple OR conditions in the flows.

What's the best way to achieve this?

1 1 356
1 REPLY 1

YES!

This is a challenge, and it can be frustrating when you first encounter it. If you modify the verb, and you've used the request.verb in your Condition, then the proxy response flow that you want to execute, may not execute.

You said

I don't want to over-complicate this by store variables and having multiple OR conditions in the flows.

But storing and restoring the variable is really the only way to do it. Save and restore the original verb, before and after the target flow executes. For example:

  <PreFlow name="PreFlow">
    <Request>
      <Step><Name>AV-SaveOriginalVerb</Name></Step>
    </Request>
    <Response>
      <Step><Name>AV-RestoreOriginalVerb</Name></Step>
    </Response>
  </PreFlow>
  <Flows>
    <Flow name="flow1">
      <Request>
        <Step><Name>Policy1</Name></Step>
        <Step><Name>Policy2</Name></Step>
      </Request>
      <Response>
        <Step>
          <Name>Policy3</Name>
        </Step>
      </Response>
      <Condition>(proxy.pathsuffix MatchesPath "/t1") and (request.verb = "POST")</Condition>
    </Flow>

In the above, the AV-* policy are assignMessage, which actually assign a variable. Like this:

<AssignMessage name='AV-SaveOriginalVerb'>
  <IgnoreUnresolvedVariables>false</IgnoreUnresolvedVariables>
  <AssignVariable>
    <Name>original_verb</Name>
    <Ref>request.verb</Ref>
  </AssignVariable>
</AssignMessage>
<AssignMessage name='AV-RestoreOriginalVerb'>
  <IgnoreUnresolvedVariables>false</IgnoreUnresolvedVariables>
  <AssignVariable>
    <Name>request.verb</Name>
    <Ref>original_verb</Ref>
  </AssignVariable>
</AssignMessage>

Can you try this?