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:
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
Solved! Go to Solution.
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.
Forgot to add, this is the response I get back:
code message details ---- ------- ------- 500 Unable to complete operation. {Unable to perform deleteFeatures operation.}
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.