ArcGIS Javascript Api - QueryTask and setDefinitionExpression

3749
1
03-11-2015 03:13 PM
PeterHunt3
New Contributor

I've written some code to query a Feature Layer using either a QueryTask or using the setDefinitionExpression when adding the layer.

For testing I am using the ASP.Net Development Server.

I've noticed (via Fiddler) that when my "where" statement is large, my request automatically changes from a GET to a POST.  Occasionally however my request fails with an "esri.config.defaults.io.proxyUrl is not set." error.

In researching this error I have found that it may be due to the length of the URL exceeded the maximum length, and that to workaround this issue I should use a proxy, in order to perform a POST.  I am however confused by this because I am already seeing my requests change from using a GET to a POST.

When performing a query using a large where clause,does the request in fact get changed from a GET to a POST when necessary?  If so, is the use of a proxy still necessary in this case.

0 Kudos
1 Reply
TracySchloss
Frequent Contributor

Yes, that's exactly what is happening.   You don't need to keep track of GET vs POST, it's going to switch itself as needed.  This behavior is one of the main reasons I've had to use a proxy configuration.  If you look in the proxy documentation, your scenario is one of the situations where you'll need one.   Different browsers have different character cutoffs, so you can't even rely on keeping an eye on the length of your where clause and know it will or won't work all the time.