Apigee - Conditional Flows - Can a conditional flow be added only to response pipeline ?

Hello Everyone ,

Came across below use case related to Api Proxy flows. As per flow diagram in Apigee docs, conditional flows can be attached to request / response pipelines.

I have a use case where i have created a new flow in Target Endpoint where my condition is execute the flow when response status code is 404. Interestingly, it doesn't work.

1006-screen-shot-2015-08-25-at-44858-pm.png

Flow condition executes for both Request & Response pipelines but i would like to add this flow only to response pipeline. Is it possible ?

Is Apigee API Proxy flow defined as , Client ->Target ->Client ?

Or Can i have two different flows like , Client -> Target , Target -> Client ?

<Flow name="notfound">
    <Description/>
    <Response>
        <Step>
            <Name>Assign-Message-1</Name>
        </Step>
    </Response>
    <Condition>message.status.code is 404</Condition>
</Flow>

I expect above flow to work only in response pipeline, but it doesn't !! Any pointers ? @Maruti Chand

Cheers,

Anil Sagar

Solved Solved
0 13 2,389
2 ACCEPTED SOLUTIONS

Not applicable

Hi @Anil Sagar , Do you have your success.codes set in the HTTPTarget connection ? else the execution flow goes to the fault handling right . Probably you missed it ?

Ref : http://apigee.com/docs/api-services/reference/endpoint-properties-reference#targetendpointtransport...

View solution in original post

Thank you @Maruti Chand for answering same. Just summarising here,

So, Answer is :

  • Apigee API Proxy conditional flow defined as , Client ->Target ->Client .
  • We cannot have a condition flow only for response pipeline. Condition gets executed in both request & response pipelines.

View solution in original post

13 REPLIES 13

Hey Anil - The condition might not be firing. Try replacing your "is" operator with "=" and see if that works. You can also try the response.status.code variable to see if that gives you any love.

I don't think "is" is supported. I found a couple of examples in the docs where "is" was used, and I've changed those to "=".

@Floyd Jones , It doesn't work. I have also tried with response.status.code and result is same. Flow Condition executes for both request and response pipelines, response status code is not available when i compare against 404 code. What i would like to achieve is flow condition only on response pipeline. @Maruti Chand @sriki77 @Madhan Sadasivam @Prashanth Subrahmanyam Any Idea ?

        <Flow name="notfound">
            <Description/>
            <Response>
                <Step>
                    <Name>Assign-Message-1</Name>
                </Step>
            </Response>
            <Condition>message.status.code = 404</Condition>
            <Request/>
        </Flow>

1007-screen-shot-2015-08-26-at-101053-am.png

Not applicable

Hi @Anil Sagar , Do you have your success.codes set in the HTTPTarget connection ? else the execution flow goes to the fault handling right . Probably you missed it ?

Ref : http://apigee.com/docs/api-services/reference/endpoint-properties-reference#targetendpointtransport...

@Maruti Chand , Yes you are right. Adding success.codes solved part of problem. Thank you!! Conditional flow now executes as expected. But other issue still i see is it still executes for both request & response pipelines. Above condition on request pipeline doesn't make any sense. Question is can we have conditional flow only for response pipeline ?

Is Apigee API Proxy flow defined as , Client ->Target ->Client ?

Or Can i have two different conditional flows like , Client -> Target , Target -> Client ?

condition you mention is for the whole flow .

2 things you can do here

#1 have your condition on your step in response or

#2 dedicate this flow only for this condition and have a different flow for request processing if you have more steps

@Maruti Chand So , Are you saying Apigee Conditional flow always executes on both Request & Response pipelines no matter what ? Because if you see above flow diagram representation one can assume that a conditional flow can be attached only to response pipeline. Regarding #2, My issue is this condition executes in request pipeline too. Can we avoid this ? I mean execution , forget about policies. See below trace. My flow condition execute for both request & response pipeline.

1008-screen-shot-2015-08-26-at-114422-am.png

So, Answer is : Is Apigee API Proxy flow defined as , Client ->Target ->Client ? Right ? We cannot have a condition flow only for response pipeline ? Right ?

Its 'yes' when you don't have any steps in the Request for that flow + condition but the condition gets executed even in the request pipe line .

Thank you @Maruti Chand . @docs team can we update this information in Understanding Flows page ?

Thank you @Maruti Chand for answering same. Just summarising here,

So, Answer is :

  • Apigee API Proxy conditional flow defined as , Client ->Target ->Client .
  • We cannot have a condition flow only for response pipeline. Condition gets executed in both request & response pipelines.

Thanks, guys. @Anil Sagar, apologies for not fully understanding the need! I get what you're asking now. So yes, the <Condition> element is available only for the entire flow. Condition isn't available inside <Request> or <Response>. So the condition is evaluated throughout the entire flow, whether or not there's anything to execute if it evaluates to true.

I'm guessing the use case is that you want to execute things in the request based on one condition, and if you get a 404 in the response, do something else, correct?

@Floyd Jones , Yes, condition executes for both request and response. Ideally i would like to execute condition only on response. That's not possible right now. No matter what condition executes in both request & response pipelines. In my case in request condition evaluates to false because response code doesn't make sense in request pipeline. Can we add this information to doc ? Or Do you think it will confuse developers and let the documentation as it is ?