I would like to dynamically set the target url to values from the KVM (to configure url that differ between test and prod environments)
I tried to get it that way but apparently it wrong:
<HTTPTargetConnection> <URL>{configs.payments-storage-service.targetUrl}</URL> </HTTPTargetConnection>
I can not use TargetServers configuration as it is not accessible in my JS scripts files
Solved! Go to Solution.
Hi @YuriAbaev,
You have to use Javascript callout in target pre-flow to build target URL all including query parameters as they will not be passed automatically.
Use this code for setting target URL.
var targetUrl = context.getVariable("configs.payments-storage-service.targetUrl"); //get the path suffix var pathsuffix = context.getVariable("proxy.pathsuffix"); //get Query string var queryString = context.getVariable("request.querystring"); context.setVariable("target.url", targetUrl + pathsuffix + queryString );
Also, the approach described above will not work with HTTPTargetConnection in TargetEndpoint configuration. That approach works only in Service Callouts.
Hope this helps!