You can translate the question and the replies:

API filtering with array of values in POST body

Hello team, I am currently having an issue with the following case : I have an endpoint on my Denodo REST API on which I am trying to make a POST query with multiple parameters on the body which can be arrays of values (multi criteria search endpoint). The problem is when I am trying to pass array of values in the body like this : ``` { "IssuerCountry": [ "GERMANY", "FRANCE", "JAPAN" ], "InvestorName": "Test", } ``` It doesn't work and the filtering is not applied with this array. Is there a way to make this kind of use case work ? Also I was wondering if there is a way to pass "null" parameters (not taken in account by the filtering, when the value isn't fed), since I am building these queries from a .NET backend that transforms a C# model directly into the JSON sent in the body of the query and some criteria can be "empty". Thank you in advance Regards
user
25-06-2021 04:58:02 -0400
code

6 Answers

Hi, Generally, in a REST API a POST request is used to update an existing resource or insert a new resource in the original source. In case I wish to filter the values using REST API, then I could use the **$filter** in the REST API URL to filter the data being displayed. I would use the following URL syntax to filter the output: ``` http://host:port/server/database/webservicename/views/Viewname/?$filter=field1 > <value> ``` You can take a look at the[ Input Parameters of the RESTful Web Service](https://community.denodo.com/docs/html/browse/latest/en/vdp/administration/restful_architecture/restful_web_service/input_parameters_of_the_restful_web_service) section of the Virtual DataPort Administration Guide for more information on how to filter the output of a REST web service. As for passing null values to the keys in the JSON body, I would be declare only the Key for the column and leave the value empty when passing the values in the JSON body. The values would be inserted as long as the underlying source accepts the input. If you still need help and you are valid support user, then you can raise a new Support case at the[ Denodo Support Site ](https://community.denodo.com/answers/question/details?questionId=9064u000000L8QUAA0&title=Need+details+for+denodo+testing+tool+jar)so that our Support Team will assist you. Hope this helps!
Denodo Team
28-06-2021 08:15:29 -0400
code
Hello, Thank you for your answer, we are using POST in this particulier case because of the fact the GET URL character limit of 2048 may be reached since it's an endpoint for search purposes accepting lots of criteria with multi values possibilities, is there no solution to use IN operator on multi values in POST ? Regards
user
28-06-2021 08:34:18 -0400
Hi, If the HTTP methods is set as POST Request for a REST Web service it is generally considered as a creation/modification statement for the underlying source table. If I wish to create a view using the response got from the POST request in the Virtual DataPort server, I would perform the following steps: * If the POST request generates a JSON response, then I would create a [JSON data source](https://community.denodo.com/docs/html/browse/latest/en/vdp/administration/creating_data_sources_and_base_views/json_sources/json_sources) with HTTP Client as the route. * In the Edit HTTP Connection dialog, I would use the HTTP Method as POST and provide the value in the POST body as an interpolation variable. * If the POST request does return a response result, then I would simply use a GET request with interpolation values in the URL and provide the value when creating the base view. I would use the following URL format: ` http://<hostname>:<port_number>/server/<databasename>/<web servicename>/views/<viewname>?$filter=@{INTERPOLATION_VALUE}` OR * I would use the IN operator in the GET URL to get only the results that match the filter condition ` http://<hostname>:<port_number>/server/<databasename>/<web servicename>/views/<viewname>?$filter="<field_name>" IN (<conditions>)` Suppose, if you still need help and you are a valid support user, then you can raise a new Support case at the[ Denodo Support Site ](https://support.denodo.com/)so that our Support Team will assist you. Hope this helps!
Denodo Team
07-07-2021 06:47:56 -0400
code
Thank you for your answer but I dont think it solves the issue, my current case is the following : - I have a view published on a RESTFUL webservice - I want to query this view by using a lot of filters (multi-criteria search purpose) using IN operator (multi-values) and date comparison operators (<, >, BETWEEN) - We can't use the GET querying (as shown in https://community.denodo.com/docs/html/browse/7.0/vdp/administration/restful_architecture/odata4_service/odata4_service_querying_data_advanced) because the URI may exceed the 2048 characters limit since there may be a LOT of criteria - If I use filtering via POST body i can't use IN operator, neither date comparison operator since it seems that there is no way to do advanced filtering via POST body Is there any way to deal with this issue according to you ? Regards
user
12-07-2021 08:45:40 -0400
Hi, When there are character restrictions on the URL to use a GET request, I would perform the following steps in a REST client(Eg: Postman) to use a POST request as a GET request: * I would set the **HTTP method** as **POST** for the URL. * In the **header**, I would provide the following header to override the POST method with GET ``` X-HTTP-Method-Override: GET ``` * In the body of the POST request, I would give the value for the **$filter** key as follows: ``` { "$filter": "<Column_name> in (conditions)", "$filter":"(<text_typecolimn> eq '<value>' or <text_typecolimn> eq '<value>')" } ``` You can take a look at the [Tunnel HTTP Methods Inside Another HTTP Method (X-HTTP-Method-Override)](https://community.denodo.com/docs/html/browse/8.0/en/vdp/administration/restful_architecture/restful_web_service/input_parameters_of_the_restful_web_service#tunnel-http-methods-inside-another-http-method-x-http-method-override) section of the Virtual DataPort Administration Guide for more information on the override HTTP method header. Hope this helps!
Denodo Team
19-07-2021 07:27:59 -0400
code
Thank you a lot for this answer, it is exactly what we needed ! Regards Florian
user
21-07-2021 10:42:35 -0400
You must sign in to add an answer. If you do not have an account, you can register here