How to set dynamic URL parameters in a call template?

Hey Remy,

that’s possible with the current versions of M10074 and M7899
In general, calls are being executed by using the process ‘N_Call Template Build, Execute, Process’. This process has a parameter called ‘parameters’ of type ‘List<Tuple<String,Mixed>>’.
For calls like POST, PUT etc. this parameter is used to build a body.. For GET calls, this list can be used to build up a dynamic URL.
See the steps below for an example:

Using query parameters in GET calls

  1. Create a call template for a GET call. As an example, I use the free weather API from open-meteo.com by calling https://api.open-meteo.com/v1/forecast

  2. I want to get the temperature for Hamburg, so I have to pass the following query parameters:

  • latitude = 53.5507
  • longitude = 9.993
  • hourly = temperature_2m
  1. To pass these to the process, I first have to rewrite the key-value pairs in the format of a ‘List<Tuple<String,Mixed>>’. The format looks like this “[ <“key1”,“value1”>,<“key2”,“value2”> … ]”, so in our example we get:

[ <“latitude”, “53.5507”>, <“longitude”, “9.993”>, <“hourly”, “temperature_2m”> ]

  1. Then, I execute a test call with the test panel:
  2. The call is executed successfully and contains the correct query parameters:
  3. For your custom use case, make sure to pass the list of tuples to the process “N_Call Template Build, Execute, Process”. You can do so for example by configuring a scheduled task. Here, you can define an expression for the “parameters” list, which dynamically determines the correct parameters per execution.

Using path variables in GET calls

Maybe the steps above are not enough to complete your goal. As you can see, the base URL “https://api.open-meteo.com/v1/forecast” is static and remains unaffected. But what if we also want to call “https://api.open-meteo.com/v1/dwd-icon” for weather data from the German weather service (DWD) with the same call template?

We can extend the base URL of a call template by using a “path variable”.

  1. Create a call template and set the fixed base URL that won’t change. In our example, that is “https://api.open-meteo.com/v1”.
  2. Then we define a parameter list, like above, but with a new special item:

[ <“latitude”, “53.5507”>, <“longitude”, “9.993”>, <“hourly”, “temperature_2m”>, <“n_pathvariable”, “forecast”>]

  1. The key “n_pathvariable” is a special hard-coded key. Its value is evaluated and then added to the base URL with a “/”. So, when I execute a test call, I get the same result as in the previous example.
  2. To toggle between “forecast” and “dwd-icon” one simply has to change the value of the “n_pathvariable” item to “dwd-icon”

[ <“latitude”, “53.5507”>, <“longitude”, “9.993”>, <“hourly”, “temperature_2m”>, <“n_pathvariable”, “dwd-icon”>].

  1. The resulting call looks like this: