[GIS] 10.3 js callback appended to query call not working

arcgis-10.3arcgis-javascript-apiarcgis-serverjavascript

I have two 10.3 ags servers that i thought were the same. But on one i can send this request to the rest api endpoint and it does not work:

http://xeballl03/arcgis/rest/services/Integrator/RouteMap/MapServer/3/query?f=json&where=STATE_NAME%3D%27Hawaii%27&returnGeometry=true&spatialRel=esriSpatialRelIntersects&outFields=*&callback=dojo.io.script.jsonp_dojoIoScript5._jsonpCallback

returns

dojo.io.script.jsonp_dojoIoScript5._jsonpCallback({"error":{"code":400,"message":"Failed to execute query.","details":[]}});

but on my other 10.3 server this does work

http://xeballl03/arcgis/rest/services/Integrator/RouteMap/MapServer/3/query?f=json&where=STATE_NAME%3D%27Hawaii%27&returnGeometry=true&spatialRel=esriSpatialRelIntersects&outFields=*

the call with the extra param in the url is being generated by a client app that i have (js api 2.0). How is that extra part generated? is it a setting in the js api?

Best Answer

the callback param is included automatically by the JSAPI because it assumes that the server does not support CORS.

starting with version 3.0 both an automatic CORS check and the ability to declare CORS enabled servers manually were introduced.

all that said, there something must be wrong with your request or the instance of ArcGIS Server though, because just because a server supports CORS doesn't mean it should fail to respond to a JSONP request.

furthermore, an identical request to this 10.3 sample server returns the appropriate feature.

http://sampleserver6.arcgisonline.com/arcgis/rest/services/Census/MapServer/3/query?f=json&where=STATE_NAME='Hawaii'&returnGeometry=true&spatialRel=esriSpatialRelIntersects&outFields=*&callback=dojo.io.script.jsonp_dojoIoScript5._jsonpCallback

Related Question