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.
Transformer: return "path?filter1=2";
For the query, I append the transformer value: {{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 {{decodeURIComponent(transformer.value)}}
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.
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”;
But when using this transformer in a query with
{{transformer.value}}
the value returned by the transformer is partly encoded.
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.
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 :
{{ ‘https://jsonplaceholder.typicode.com’ + ‘?data=1’ + ‘&complexFilter=var=1’}}