REST API Query String (initial section of query)

Our API has an off-method of formatting query filters, and I am trying to find a way to include the initial part of the needed query string and have it concatenated with the users input.

Probably better I try and describe it visually:

Here is the complete path with full query string:

https://awesomeapp.com/api/records/products?filter=name,cs,SEARCHSTRING

Response key path: records

Query parameter: Label, search, Key, filter, value type, string

On the Products List page I have set up:
Page Variable: searchQuery, string
Data Variable Product, collection of data records, Page Variable Value searchQuery

And on the Products List Page I started with a SearchBar with the input bound to the searchQuery Page Variable value, but I still need to add “name,cs,” to the start of the users input. For example, if the input is “calvin”, the complete string sent to the API for the search query would be “name,cs,calvin”.

I tried to use Formula for the Search Bar input value using the following formula:

“name,cs,” + pageVars.searchQuery

But the search query wasn’t correct. Also, the input field is prepopulated with the string “name,cs,” and this isn’t ideal.

Any pointers?

Cheers, Billie

Your thinking is correct, but the input field value needs to be bound to pageVars.searchQuery, whereas the data variable’s filter input argument needs to be bound to "name,cs," + pageVars.searchQuery.

It’s actually a bug that you can even bind read-only values such as formulas to value type fields, since that would imply whatever the user types in the field is set to the “formula” – which might make kinda sense if the formula was just e.g. pageVars.searchQuery, but really doesn’t, since that’s really the value of pageVars.searchQuery at the time the formula gets executed, and not a two-way reference to the variable itself like a direct page variable binding is. If you consider a formula like "text" + pageVars.variable, it makes even less sense.

2 Likes

Thank you Harri!

I am so impressed that you take the time to provide such detailed and valuable support.

1 Like