ByPass Service Call Out Policy on basis of some query parameter in Request

I have a Service Callout Policy along with other policies in my API Proxy which calls some service.

Now I have a requirement where on the basis of some query parameter in the request , I have to bypass the Service CallOut policy and just forward the whole request (along with headers, queryparams etc) to the next policy in API Proxy which means that ServiceCallOut Policy should not be executed at all.

How I can achieve that ? Is there any policy ?

Thanks

Gaurav

0 4 380
4 REPLIES 4

Hi, in your flow you could add condition for policy execution. i.e if queryparameter is present and it has specific value then only service callout should execute.

Not applicable

Hello @GAURAV,

What I would do like, I would put a condition with the policy, something like this:

<Step> 
	<Condition>(request.queryparam.ABCD = "true")</Condition> 
	<Name>MyServiceCallOutPolicy</Name> 
</Step>

Does it help ?

Hi @MEGHDEEP BASU

Thanks for the response.

Also Is there a way where I can have a condition inside my Service CallOut Policy as highlighetd in BOLD to execute two different services (URL) like below

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ServiceCallout async="false" continueOnError="true" enabled="true" name="AuthenticateUser">
    <DisplayName>Authenticate User</DisplayName>
    <FaultRules/>
    <Properties/>
    <Request clearPayload="true" variable="myRequest">
        <IgnoreUnresolvedVariables>false</IgnoreUnresolvedVariables>
    </Request>
    <Response>calloutResponse</Response>
    <HTTPTargetConnection>
        <Properties>
            <Property name="response.retain.headers.enabled">true</Property>
            <Property name="request.retain.headers.enabled">true</Property>
        </Properties>

	//Condition 1 based on some request query param
        <URL>http://test1.com:80/openam/json/authenticate1</URL>

	//Condition 2 based on some request query param
	<URL>http://test1.com:80/openam/json/authenticate2</URL>
	
    </HTTPTargetConnection>
</ServiceCallout>

Hello @GAURAV, I do not think we can do so (calling different backend URLs from the same service callout policy, based on some condition). But as I specified earlier, we can have different service callout policies each having a specific condition to hit a definite backend URL.