Select to view content in your preferred language

Why a proxy error when using QueryTask?

1058
2
Jump to solution
10-18-2012 01:03 PM
SteveCole
Honored Contributor
This is just bizarre.

In the attached screenshot, you'll see two vertical cyan polyline features belonging to the same feature layer (and served up as a dynamic map service). I have an infoWindow set up for the feature layer and when it opens, it takes the feature's geometry and then runs a queryTask against a polygon feature layer also on the map (thin blue outlines with no fill in the screenshot).

Now, when I click on the left cyan feature, my queryTask runs just fine. When I click on the righthand cyan feature, it returns a message to the console window: "esri.config.defaults.io.proxyUrl is not set" and basically fails.

Same dataset but different outcomes. Why is that??

Steve

[ATTACH=CONFIG]18558[/ATTACH]
0 Kudos
1 Solution

Accepted Solutions
derekswingley1
Deactivated User
It comes down to the size of the geometry of your feature. Due to browser restrictions, when a URL is > 2k characters, the API uses a proxy. When you execute a queryTask, the geometry is sent as part of the URL (take a look in your browser's dev tools). Depending on how many vertices make up the feature's geometry, a URL can exceed the 2k character limit. I'm guessing that's what's happening here??? one feature has a few vertices so it doesn't need the proxy. When a larger feature is used, the URL is longer so a proxy is required.

View solution in original post

0 Kudos
2 Replies
derekswingley1
Deactivated User
It comes down to the size of the geometry of your feature. Due to browser restrictions, when a URL is > 2k characters, the API uses a proxy. When you execute a queryTask, the geometry is sent as part of the URL (take a look in your browser's dev tools). Depending on how many vertices make up the feature's geometry, a URL can exceed the 2k character limit. I'm guessing that's what's happening here??? one feature has a few vertices so it doesn't need the proxy. When a larger feature is used, the URL is longer so a proxy is required.
0 Kudos
SteveCole
Honored Contributor
Thanks, Derek.

Your explanation makes perfect sense now. The left feature is very basic so it the POST url is under the 2k character threshhold. The right feature has about 35 vertices due to the curves. I looked at the POST info and the vertex coordinate pairs are almost 40 characters long so I'm already at about 700 characters with just the definition of the linear feature.

I'm not currently specifying a proxy using esri.config.defaults.io.proxyUrl but I'll be working with my IT to finally get that set up.

Thanks again!
Steve
0 Kudos