I'm trying to execute this (it's JavaScript but it doesn't matter):

queryTask.execute(query, function (results) {

and I get an error:

Failed to execute query

These are the parameters:

var queryTask = new esri.tasks.QueryTask(path);
var query = new esri.tasks.Query();

To show how are defined what I get with them, console.log shows this:

console.log('query', query);

outFields: Array(1)
0: "*"
length: 1
__proto__: Array(0)
returnGeometry: false
spatialRelationship: "esriSpatialRelIntersects"
where: "codigo_pos = 8150215"

console.log('queryTask', queryTask);

gdbVersion: undefined
normalization: true
source: undefined
url: "https://arcgis.XXX.com/arcgis/rest/services/XXX/XXX/MapServer/4"
_countHandler: ƒ ()
_errorHandler: ƒ ()
_executeForIdsHandler: ƒ ()
_extentHandler: ƒ ()
_handler: ƒ ()
_relationshipQueryHandler: ƒ ()
_url: {path: "https://arcgis.XXX.com/arcgis/rest/serv…XXX/XXX/MapServer/4", query: null}
__proto__: Object

Any idea?

  • Could you please check the result from the query using the dev tools (Network tab)? It probably gets you a better approach about what is going on
    – Katah
    Commented Jul 2, 2019 at 13:50

1 Answer 1


Calling queryTask.execute(params) returns a promise,
in order to handle the results, read the results via the then clause

queryTask.execute(query).then(function(results){ console.log(results.features); });

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.