Select to view content in your preferred language

JSON input for deleteFeatures

676
2
Jump to solution
10-28-2019 06:07 PM
ITAdmin6
New Contributor II

Hi 

I have a script that accesses the REST API to add, update and delete features. Because I'm making a number of changes at a time I'd like to send through multiple changes per request. Currently I have add and update working but can't get delete to work. 

I'm not sure if I've got the JSON format wrong or whether deleteFeatures doesn't take JSON as the body of a request. I've got it to delete with the parameters in the URL:

https://<server>:6443/arcgis/rest/services/<folder>/<featurelayer>/FeatureServer/5/deleteFeatures?f=...

However if I omit the &where and post some JSON it doesn't work (this way matches the add and update format that works for me):

features=[{"attributes":{"OBJECTID":4715756}},{"attributes":{"OBJECTID":4715757}},{"attributes":{"OBJECTID":4715758}},{"attributes":{"OBJECTID":4715759}},{"attributes":{"OBJECTID":4715760}},{"attributes":{"OBJECTID":4715761}},{"attributes":{
"OBJECTID":4715762}},{"attributes":{"OBJECTID":4715763}},{"attributes":{"OBJECTID":4715764}},{"attributes":{"OBJECTID":4715765}}]

Also tried this format:

features=[{"attributes":{"OBJECTID":"4715756,4715757,4715758,4715759,4715760,4715761,4715762,4715763,4715764,4715765"}}]

Potentially this way is not available? In the documentation, add and update have example JSON input but delete does not.

Thanks

Matt

0 Kudos
1 Solution

Accepted Solutions
ITAdmin6
New Contributor II

Reading the documentation a little closer I see I got the format a little wrong. However no matter what I tried and what format I had the data in I couldn't get the JSON format right.

However I managed to reverse a c# library to can post objectids using 'application/x-www-form-urlencoded' as the format of the body.

So the body ends up looking like:

"objectIds=<objectid>%2C<objectid>%2C<objectid>%2C<objectid>" 

The %2C represents commas.

A little messy but gets the job done.

View solution in original post

0 Kudos
2 Replies
ITAdmin6
New Contributor II

Forgot to add, this is the response I get back:

code message                       details 
---- -------                       ------- 
 500 Unable to complete operation. {Unable to perform deleteFeatures operation.}
0 Kudos
ITAdmin6
New Contributor II

Reading the documentation a little closer I see I got the format a little wrong. However no matter what I tried and what format I had the data in I couldn't get the JSON format right.

However I managed to reverse a c# library to can post objectids using 'application/x-www-form-urlencoded' as the format of the body.

So the body ends up looking like:

"objectIds=<objectid>%2C<objectid>%2C<objectid>%2C<objectid>" 

The %2C represents commas.

A little messy but gets the job done.

0 Kudos