Passing arbitrary number of query params to a REST Resource

Is it possible to pass arbitrary number of query params to a REST Resource?

I am triggering a query in JS via trigger() and passing variables through additionalScope.

I notice that you have to pre-define what the query param fields are in the UI and assign them variables which later you can pass. However, what if I want to pass in an arbitrary query key/value pair that is only known at runtime? Markup 2023-03-24 at 19.45.23.png - Droplr

Hey @huang3r! Hmm, great question.

Would something like this work for you?

http://community.retool.com/t/how-can-i-skip-a-parameter-from-a-request-depending-on-the-value/7775

http://community.retool.com/t/conditional-property-using-query-library/12116

Basically, if you have all keys already set, then you can optionally pass them in by setting their values to something like {{additionalScopeKey || null }} to use null if there's no key.

If you have an unknown set of keys, then I think if you do something like use a Raw body and then pass in an entire dynamically created object (via additionalScope), you could get this to work. Full disclosure, I haven't actually done this before so I'm not 100% sure, but I think it might be a good option!

1 Like