TargetServers as variables ?

Not applicable

I have 10 target servers configured. When doing a javascript callout (which contains a http.send) - I want the url to be that of a defined "target server" - which would change according to environments. I don't want to hard-code the url in the script - to point to either dev/prod target. One way to do it- is maintain urls in KVM.... But is there a way to "access" the created target servers as a variable in javascript script ?

2 2 341
2 REPLIES 2

Not applicable

Similar to this discussion : https://community.apigee.com/questions/10738/how-t...

Looks like no straightforward solution for now.

@Aditya Elkunchwar, are you making multiple calls via each JS callout. If yes, then as mentioned by @sarthak on the other question that I asked - node.js is your best bet.

However, in case you are making a single call from your JS callout to a pre-defined TS and not sending the flow directly post the JS-callout to a TS, you can set flow variables via your JS and then use them in your RouteRules to redirect the flow to the appropriate TS. In other words, the above suggestion will only work if you have a flow A with a JS callout that does some processing on the request and then decides whether to forward the request to TS1 or TS2 or TSn.

Btw, have you tried using a JS Callout-ServiceCallout combo instead, since you can leverage the TS in the ServiceCallout policy?