Invoke Rest Url with dynamic value

Situation: We has a situation where we invoke a single Rest URL externally with different client Id as shown below:-


Here, you can see a parameter(clientId) embedded into the URL with different values (123, 763, 9453, 19723) after that, there is a parameter named cod* (but it could be other param/s)*

When my WebService Provider receives the URL (1 - 4), it has to call a Rest WS Consumer with the following URL and PARAMETERS (A - D)


Solution: You can do so by defining the parameter name(clientId) within curly brackets "{ }" as {clientId} in Rest WS Provider URL. Following are the steps to achieve this requirement:-

1. Simply create a Rest WS Provider and define the Url as "/client/{clientId}/check" along with other parameters "cod". Here, clientId is a variable whose value is dynamic and can be accessed as $$clientId$$ in the context variable.


2. Create a web consumer and provide rest URL like dummy or any URL that you want to define.
3. In the process flow designer, 
For Invoke URL "*123*/check?cod=125gcv", if WS Consumer call URL "*123*/check?cod=125gcv"

then you can simply override the WS Consumer restUrl by using the putContext var shown in the following screenshot and connect it to WS Consumer activity. In putContext var, select the web consumer activity name and method "restUrl" and define the value as below:-$$clientId$$/check?cod=$$cod$$


So, the Process flow contains the following activities:-
a. putContext var
b. Ws Consumer
c. Context Target

Process_flow.pngNote: In case, if the calling URL pattern is not fixed i.e. if Ws Consumer calling URL is different for every invoked URL, then you need to create a Custom Plugin to handle this and save that Url in a variable and pass this variable in a putContext var (restUrl) to override the URL present in WS Consumer.

So, in this case, the Process flow contains the following activities:-
a. Custom Plugin
b. Ws Consumer
c. Context Target


You can also refer to the below-attached Process flow.

Have more questions? Submit a request


Article is closed for comments.