Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I am developping a web application that uses a feature service, what i want to do is save the data in the feature server, and then delete all the features at the start of the application. I am able to save data in the feature service, my problem is how to delete the features in the start of the application. I found a solution to that suggesting that I use the operation: "Delete Features" of the REST API, but I think I am making a mistake in the syntax, here is my code sample:

var theurl= "***/arcgis/rest/services/edt/FeatureServer/0/deleteFeatures"
var request = esri.request({

url: theurl,
// Service parameters if required, sent with URL as key/value pairs
content: {
f: "json",
where: "1=1"}

});

I don't know what I am missing can you please help

share|improve this question

1 Answer 1

up vote 1 down vote accepted

the best way to get an idea of what you need to do in your javascript app to interact with ArcGIS Server or ArcGIS Online services successfully is to play around with the REST endpoint for a particular operation interactively and snoop the web traffic to see what requests you are sending.

in this case, the syntax you need would look something like this

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

heres a fiddle.

the featureLayer.applyEdits() method is an alternative you might explore as well.

share|improve this answer
    
It's working finally. Thank you –  user30144 May 27 at 9:32
    
its my pleasure :) –  John Gravois May 27 at 20:20

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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