Use filters in REST API to filter Array field.
I have a table, which returns following response via REST API:
{
"City": "BORRALHA",
"Parish": "Borralha",
"CAE": [
11029,
11030
],
"Projetos Relacionados": [
10776,
12135,
13112
],
"Fontes de Dados": [
2,
161,
74332
]
}
I want to filter result and get only records where CAE is 11029. So I used this REST API: ?filters={"fields":{"CAE":11029}} but I get blank result everytime. Is there any way to filter using array fields.
5 replies
-
Did you encode the filter criteria like this...
%7B%22fields%22%3A%7B%22CAE%22%3A11029%7D%7D
-
Yes, Its encoded exactly it is mentioned in documentation.
-
I couldn't filter using a value of an array field. If someone else doesn't post a solution, you could attend one of the API webinars. Please share if you get an answer.
-
I doubt you'll get it working with an array (which I guess is a multi choice field or some formula returning multiple items in an array?)
I find checking for an item in an array not to be straightforward in any case in NX. My favourite approach is to concat the array and figure out a robust regular expression that should get me a clean true or false using testx.
Your best bet may be to wrap a NX query into the api using the query endpoint and query parameter, and see if that works. eg
select YourTable[testx(concat(CAE), "\b11029\b")]
, url-encoded and appended to the below url structure.
https://api.ninoxdb.de/v1/teams/:teamid/databases/:databaseid/query?query=
from the API manual:
Execute a Ninox Script
With the following request you can execute any valid Ninox script against a database.
Few things to consider -
The output of the script will be streamed back as the response.
Scripts having any compilation errors will terminate the request with a null reponse.
RequestThe request can be executed using both GETand POST HTTP methods
GET https://api.ninoxdb.de/v1/teams/:teamid/databases/:databaseid/query?query=1+2
-
There's also the contains() function which may be simpler than testx()
Content aside
- 3 yrs agoLast active
- 5Replies
- 1471Views