How can I make some element of the URL (in HTTP task) dynamic?

Hi,

I’m calling a rest API with this URL in which notes will be created against a particular order and orderId can change depending on the order selection and thus it has to be dynamic.
https://xyz-tem.com/v2/admin/orders/**{$orderId}**/notes

I’m storing it in a variable in a script task prior to the HTTP task call, how can I ensure that the orderId that I’m storing in the script task is being populated in the URL.

I tried doing it the way shown above but it didn’t help.

Best,
s4meer

Hey.

This is the way I deal with those kind of URLs.

Prior to the HTTP task, have a Script task (like you do already). However, do something like this:

final String orderId = execution.getVariable("orderId").toString();
final String url = "https://xyz-tem.com/v2/admin/orders/@id@/notes";
final String result = url.replace("@id@", orderId);
execution.setVariable("myUrl", result);

Then, in the HTTP task, for “Request URL”, you simply put: ${myUrl}

1 Like

Thanks @fiki574
It was helpful and it worked

Cheers!