Unable to complete operation issue in 10.2

516
4
03-02-2014 10:44 PM
New Contributor
hi all ,
i m facing Unable to complete operation
here is my function to query the map server service.

function queryRetailers() {
              var random = (new Date()).getTime();

              var query = new Query();
              var queryTask = new QueryTask("........../rest/services/Places/MapServer/0");
              queryTask.DisableClientCaching = true;            
              query.outSpatialReference = { wkid: 4326 };
              query.returnGeometry = true;
              query.outFields = ["*"];
              query.where = " [RetName] = 'Lesley' AND " + random + "=" + random;           
              queryTask.execute(query, featureSetAddToMapSucess, featureSetAddToMapError);             

          }

when query execute it always throw Unable to complete operation. 400
here i have tried
1. doing dirty the query.
2. disable client cashing .
and still  no luck.i went through the forum and  doing query in post was mentioned in some answers and i have no idea on that.
Can some one  explain me the solution for this bcz it wasted my two days of work now
Reply
0 Kudos
4 Replies
Occasional Contributor II
hi all ,
i m facing Unable to complete operation
here is my function to query the map server service.

function queryRetailers() {
              var random = (new Date()).getTime();

              var query = new Query();
              var queryTask = new QueryTask("........../rest/services/Places/MapServer/0");
              queryTask.DisableClientCaching = true;            
              query.outSpatialReference = { wkid: 4326 };
              query.returnGeometry = true;
              query.outFields = ["*"];
              query.where = " [RetName] = 'Lesley' AND " + random + "=" + random;           
              queryTask.execute(query, featureSetAddToMapSucess, featureSetAddToMapError);             

          }

when query execute it always throw Unable to complete operation. 400
here i have tried
1. doing dirty the query.
2. disable client cashing .
and still  no luck.i went through the forum and  doing query in post was mentioned in some answers and i have no idea on that.
Can some one  explain me the solution for this bcz it wasted my two days of work now


Hi LesleyKarunathilaka,

Looking at the code it seems the input parameters for the query which is passed might be an issue. What you can try to do is run the application and open Developer Tools(if using IE ) or Firebug(if using Firefox) and check what is the URL that is fired for the query. You can copy that URL and run in new tab and change the parameter (f=json to f=html) and you can verify what are the input parameters going and if there is any error in the input parameters or whether there is an issue with the query to return records based on the query parameters.

Hope this helps,

Regards,
Manish
Reply
0 Kudos
New Contributor
Thanks manish it worked.now i can query the map server.But if i try to get specific outfields filter from query it fails.

when i put  query.outFields = ["*"];    it retrieve all the attributes from the layer according to the query.

but if i put query.outFields = ["VantageDB.DBO.%populated_places.ogr_fid "];  the query fails .but it is the way my layer fields exists.Can u give a answer for this and really appreciate ur support on this

Thank you.
Reply
0 Kudos
Occasional Contributor II
Thanks manish it worked.now i can query the map server.But if i try to get specific outfields filter from query it fails.<br>
<br>
when i put  <em> query.outFields = ["*"];  </em>  it retrieve all the attributes from the layer according to the query.<br>
<br>
but if i put <em>query.outFields = ["VantageDB.DBO.%populated_places.ogr_fid "];</em>  the query fails .but it is the way my layer fields exists.Can u give a answer for this and really appreciate ur support on this <br>
<br>
Thank you.


Hi LesleyKarunathilaka,

Glad that helped you. As for the outfields, if you mentioned ["*"] it will return all the fields for a particular layer.

But if you pass the exact field name that is exposed in the REST endpoint the query should query should work without any issues.

For example:

Consider the below link to a layer in a map service:

http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Census_USA/MapServer/0

so if we need to specify the out fields for this layer you can specify

query.outFields = ["HOUSEHOLDS"];

You can check in the REST endpoint for your map service and try to add the corresponding field, alternatively you can also use the alias name for the field that is being displayed in the REST endpoint.

Hope this helps.

Best Regards,
Manish
Reply
0 Kudos
MVP Regular Contributor
go to your rest endpoint and look at your field names

Try just specifying one. 

My guess is it is the "%" in your field name that is causing the problem.
Reply
0 Kudos