call different target connections based on query param

Hi ,

I need to call different target server paths based on incoming request query param value.

My incoming query param is “async” which will have either “true” or “false”.

based on the async query value, i need to change path of target .

/v1/sync/test

if async=false

/v1/sync/test

if async=true

/v1/async/test

Thanks

@Gopi Krishna M

You can do it , there are multiple options to do it.

1:Use java script - Store the query param value, compare it and set the path i.e make it dynamic

JS:
var q=context.getVariable("request.queryparam.async);
compare "q" value with true/false and set it
if(q==  "true")
context.setVariable(value,"v1/sync/test");
else
context.setVariable(value,"v1/async/test");

TargetServer:

<HTTPTargetConnection>
<LoadBalancer>
<Server name="target-server"/>
</LoadBalancer>
<Path>{value}</Path>
</HTTPTargetConnection>

Hi @Gopi Krishna M - You can also do this with conditional RouteRules, described at https://docs.apigee.com/api-services/content/understanding-routes#determiningtheurlofthetargetendpoint-conditionaltargets.