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!

Hi @ben
I'm having the same and similar problem here.

So this is Clickup API and I wanted to omit the query key when it's messing its assigned input value thus using transformer to build an entire URL.

In console my URL looks OK but the API request throws an error saying something like below.


This value comes from a static option.

So it's preserving double quotations and braces by escaping them??
How can I avoid this error?

If I comment out this list_id[]=... part it works.



Hey @KMimpact! I suspect this has something to do with the fact that you're passing in the whole URL as a string here:

So your URL ends up being something like


instead of[]=163675161

where the number is a number in the second option, and not just a part of the string.

Do you know if your end point is okay if you try hardcoding the URL as a full string?

Hi @victoria
Thank you for your response.
The same issue of this main topic from vladt happened to me and executed what ben suggested here.

As I wrote this works fine without list_id[] part.

This is not working either.
*Still, if i remove the construction of list_id parameter it works.

If you try pasting in the exact URL string directly, does it throw the same error?