Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

How to set target url with a KeyValueMap property

Not applicable

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 Solved
0 11 4,632
1 ACCEPTED 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!

View solution in original post

11 REPLIES 11
Top Solution Authors