How to use search.in in $filter for APIM
Hello, All,
When I try to use in $filter in APIM (via http GET as a query string parameter):
search.in(Var, 'Val1, Val2')
(I also tried search.in(Var, 'Val1,Val2', ',') with the same result)
I get an error: "Invalid token detected in position 0"
But when I use for the same query:
Var eq 'Val1' or Var eq 'Val2'
I get the expected result. What am I doing wrong? I have this documentation as reference: https://learn.microsoft.com/pt-br/azure/search/search-query-odata-search-in-function
Thanks in advance.
Azure Functions
-
VenkateshDodda-MSFT • 23,441 Reputation points • Microsoft Employee
2025-01-09T12:47:08.5366667+00:00 @Leonardo Machado Thanks for posting your question in Microsoft Q&A.
Could you please help us in understanding are trying to apply the filter to Azure Search in search explorer or in APIM or in any other Azure Service.
So that I can tag the right SME to assist you further.
-
Leonardo Machado • 0 Reputation points
2025-01-09T12:48:16.4966667+00:00 I am using APIM
-
VenkateshDodda-MSFT • 23,441 Reputation points • Microsoft Employee
2025-01-09T13:02:16.3866667+00:00 @Leonardo Machado Also could you please share more information what exactly you are trying to do? also where are you using these $filter and what is the actual output vs expected output.
-
Leonardo Machado • 0 Reputation points
2025-01-09T14:48:46.58+00:00 Sure: there is an APIM service available via HTTP. I am using Thunder Client to make the http GET request (but I could be using any other http client)
-
Leonardo Machado • 0 Reputation points
2025-01-09T14:49:15.34+00:00 The $filter is a query string parameter in http GET
-
Leonardo Machado • 0 Reputation points
2025-01-09T15:23:11.0533333+00:00 As explained above: When I use in $filter:
Var eq 'Val1' or Var eq 'Val2'
The output is as expected: a valid json with results according to Var being equals do 'Val1' or 'Val2'
When I use in $filter an equivalent expression I get a json indicating an error: "Invalid token detected in position 0" (as if the "search.in" expression is not recognized as valid)
-
VenkateshDodda-MSFT • 23,441 Reputation points • Microsoft Employee
2025-01-09T15:34:47.0433333+00:00 @Leonardo Machado Thanks for sharing the details, do you have any policy written in your api and query these parameters? if yes please do share the policy.
could you please share the screenshots of the portal what you are doing and also the documentation you have shared above is related to Azure Search service not related to Azure APIM. -
Leonardo Machado • 0 Reputation points
2025-01-09T15:58:51.08+00:00 I cannot share the screenshots for the portal, for legal reasons.
As for the policies, where do I get this information in the APIM portal? I am able to query a given parameter using "eq" operator. Why wouldn't I be able to query the same parameter with another operator ("search.in")?
-
Pinaki Ghatak • 5,560 Reputation points • Microsoft Employee
2025-01-13T10:27:05.2266667+00:00 Hello @Leonardo Machado Based on the error message you provided; it seems like there might be an issue with the syntax of your
search.in
function call. Thesearch.in
function takes three arguments:- the field or range variable to compare,
- the list of values to compare it against, and
- an optional delimiter to separate the values in the list.
Here's an example of how you can use the
search.in
function in a$filter
expression:$filter=search.in(MyField, 'Value1,Value2')
In this example,
MyField
is the field or range variable you want to compare, and'Value1,Value2'
is the list of values you want to compare it against.Note that there are no spaces between the values in the list, and there is no delimiter specified. If you are still encountering issues, please provide more information about the error message you are seeing, and our team can try to help you further.
-
Leonardo Machado • 0 Reputation points
2025-01-13T10:38:16.9066667+00:00 I tried many ways. See the detailed output below: (you will see that I don't add space in the value list. Just a comma)
When I use VoyageDe plus "eq" and "or" operators with the same values in the list I get a valid output as response.
-
Leonardo Machado • 0 Reputation points
2025-01-13T10:45:46.5566667+00:00 The complete error is as follows:
{
"Erro": {
"codigo": "400",
"mensagem": "Bad Request",
"body": {
"error": {
"code": "005056A509B11EE1B9A8FEC11C21178E",
"message": {
"lang": "pt",
"value": "Invalid token detected at position 1"
},
"innererror": {
"transactionid": "1FA041126E4E00F0E00677E6636FF456",
"timestamp": "20250113103505.6190790",
"Error_Resolution": {
"SAP_Transaction": "For backend administrators: use ADT feed reader \"SAP Gateway Error Log\" or run transaction /IWFND/ERROR_LOG on SAP Gateway hub system and search for entries with the timestamp above for more details",
"SAP_Note": "See SAP Note 1797736 for error analysis (
https://service.sap.com/sap/support/notes/1797736
)"
}
}
}
}
}
}
When I try to access the above URL in service.sap.com I get a "no data" page!
Sign in to comment