Build dynamic URL path for calling an API

Hi everybody,

We are evaluating ReTool and I got stuck into an interesting situation: I want to populate a table using a RestAPI resource, but the URL query string parameters should be dynamically calculated, such that I append the needed query string parameters Only when needed.

For this, I did a JS Transformer where I dynamically calculated a variable and I return it, representing the query string. Then, the transformer is used with the curly braces syntax directly in my query.

return "path?filter1=2";

For the query, I append the transformer value:

But when running the query I get the following error
Could not find resource for full path: [...]path%3Ffilter=2"}
suggesting there is some encoding going on here, as visible in the preview as well:

Changing the query to
makes no change (note: I cannot add a second picture since I am a new user, but its the preview of the transformer value)

What is happening? It feels like there is some encoding of the value passed to the query that cannot be controlled.

Thank you!

Second picture:

Hi @vladt! Welcome to the community! :sunglasses:

I’m not sure I’m fully understanding how you have this set up, could you share a screenshot of the REST API query?

You should be able to dynamically assign query string parameters for REST API’s within the query editor:

And then you can view the raw outbound query by pressing Preview then API Request:

Hi Ben,

So here are some more details:

  1. Dynamically assigning query parameters to the REST API is not powerful enough, so I considered using a Transformer, to write a more advanced piece of JavaScript, that can return the full query string. So, we can consider a simple transformer as
    return “filter?param1=value1”;

  2. But when using this transformer in a query with
    the value returned by the transformer is partly encoded.

Here is a full application reproducing the issue:

I hope this makes more sense now.

Thank you!

Gotcha! Thank you for sending that over!

You are correct, there is some encoding going on after the transformer value was concatenated with the base URL. I managed to get this working with a slight change to the syntax:

Is this more so what you were expecting? Another option could be return to values from the transformer in an array and then piece them together using the form.

1 Like

Thank you, it fixes the problem !



Coming back with a very similar issue, but that we cannot workaround.
The API we are trying to call is from Jira, representing a valid JiraQuery:

But there is again some transforming happening, resulting in the following query, that is not interpreted correctly by jira:

What logic/transformation is ReTool trying to apply to the query string?

Similar issue can be reproduced by having the following as a RestQuery URL :
{{ ‘’ + ‘?data=1’ + ‘&complexFilter=var=1’}}

Thank you!

1 Like