Browsers have limitation on the length of the URLs. IE has limitation that Url length should not exceed 2K characters.
When I form a $filter equals query, I could co
I defer to @Vitek's answer to the OP's question:
OData itself doesn't limit the length of the Url
But if others who arrive here because of IIS limitations : The request filtering module is configured to deny a request where the query string is too long.
, they may benefit from my answer. Follow that error's instructions:
Verify the configuration/system.webServer/security/requestFiltering/requestLimits@maxQueryString setting in the applicationhost.config or web.config file.
Follow the instructions:
<configuration>
<system.webServer>
<security>
<requestFiltering>
<requestLimits maxQueryString="50000">
</requestLimits>
...
You may also get this error:
The length of the query string for this request exceeds the configured maxQueryStringLength value.
This technique is described here and here, and it looks like this:
<configuration>
<system.web>
<httpRuntime maxQueryStringLength = "50000" ... />
OData itself doesn't limit the length of the Url, but as you noted most clients and servers do. So usually it's a good practive to not produce URLs too long.
The problem you refer to (implementing the Contains operator, or something similar) has two possible workarounds:
1) Use service operation to handle such query for you. You can possibly pass the multiple input values encoded as a string or something like that, or maybe the service operation knows these up front anyway.
2) Use the long $filter, but send the request in a $batch request. The advantage is that the limit on the Url is much bigger and it's very unlikely you will hit it. The disadvantage is that even though you're trying to execute a GET request, due to the $batch it travels as POST request over the web and thus it won't be cached.
I didn't find how the $batch
is used. so I used $filter
for sending a long request. Its pretty easy:
DataServiceQuery<CLIENT> ordersQuery = DataServiceQuery<CLIENT>)this.context.CLIENTS.AddQueryOption("$filter", MyFilter());
where MyFilter()
return a string like this: "ID_CLIENT = 1 or ID_CLIENT = 2"
NB: Dont use the uppercase AND. it leads to and error. use and
not AND