feature service rest request syntax

4730
4
02-25-2013 10:46 AM
ZorbaConlen
Occasional Contributor
Hi,
I'm using ajax to make requests to feature services to add, edit or delete. I have this working for adding features like this.

urlParams = "[{'attributes' : {'AssetNumber' : '" + asset + "', 'Description' : '" + description + "'}}]";
var url = esri.urlToObject("http://xxxxx/ArcGIS/rest/services/ArcGISOnline/FOGIncidents/FeatureServer/1/addFeatures?features=" + urlParams + "&f=json");
 var requestHandle = esri.request({ 
    url: url.path,
 content: url.query,  
    load: addFogRequestSucceeded, 
    error: addFogRequestFailed 
  }, {useProxy:true, usePost:true});


This works great. But when it comes to the delete operation, I'm having trouble figuring out the syntax. This is not really documented in enough detail to be useful. I know that I can either provide a where clause or a list of obectids, but I need the exact syntax.

I think it would be something like:

urlParams = "'where' : 'incidentID = 1'";
  var url = esri.urlToObject("http://xxx/ArcGIS/rest/services/ArcGISOnline/FOGIncidents/FeatureServer/1/deleteFeatures?" + urlParams + "&f=json");
  var requestHandle = esri.request({ 
    url: url.path,
 content: url.query,  
    //load: delFogRequestSucceeded, 
    //error: delFogRequestFailed 
  }, {useProxy:true, usePost:true});


Are examples documented anywhere? ESRI?

Could also use help with edit, add attachment and delete attachment.

Thanks.
0 Kudos
4 Replies
JanelYang
New Contributor III
Zorba,

A reference can be found here. You can find the syntax in the deleteFeature operation. Editing operations for attachment are also documented in the same site.

Jerome
0 Kudos
ZorbaConlen
Occasional Contributor
Jerome, thanks for the info. I know about that documentation, but feel that it lacks a useful example for what I'm trying to do.

I ended up switching tacks a bit and got this to work using the applyEdits operation on the feature service.

The syntax is like:

var url = esri.urlToObject("http://webservices.nwmaps.net/ArcGIS/rest/services/ArcGISOnline/FOGIncidents/FeatureServer/1/applyEdits?deletes=" + String(incidentID) + "&f=json");


incidentID in above code is an alias for objectid. ApplyEdits does either an add, edit or delete operation depending on the parameters so it gets what I'm after.

Still would like to see this spelled out better in ESRI REST docs.
EricMahaffey
New Contributor III

Zorba, I'm having the same issue.  There's no examples of the "deleteFeatures" request syntax anywhere. So frustrating.

0 Kudos
RobertMueller_Jr1
New Contributor III

Zorba and Eric -

I'm sure you two have moved on from whatever you were working. But in the hopes clearing up the above requests for future people - See using REST "delete features" in arcgis api for javascript - Geographic Information Systems Stack Exc...

This should be you answer:

esriRequest({
  "url": "http://sampleserver6.arcgisonline.com/arcgis/rest/services/ServiceRequest/FeatureServer/0/deleteFeat...",
  "content": {
  "objectIds": 123,
  "f": "json"
  }
  }, {"usePost": true
  });

0 Kudos