Help! can't edit featureservice

2694
5
Jump to solution
01-19-2012 09:57 AM
LisaT
by
Occasional Contributor III
Hi,
I have been trying to get help from a thread posted by another user (listed at bottom of this post), but it seems as if no one is watching it anymore.  I want to use a featureservice to make edits.  I have created the featureservice and can delete from the services directory.  When I use the services directory, the url is: "myservice/ArcGIS/rest/services/folder/myfeatserv/FeatureServer/0/deleteFeatures"

The parameters sent are: objectIds=6&where=&geometry=&geometryType=esriGeometryEnvelope&inSR=&spatialRel=esriSpatialRelIntersects&f=html"

This effectively deletes objectId 6.

However, if I use the same url: window.open("myservice/ArcGIS/rest/services/folder/myfeatserv/FeatureServer/0/deleteFeatures?objectIds=6&where=&geometry=&geometryType=esriGeometryEnvelope&inSR=&spatialRel=esriSpatialRelIntersects&f=html");
  
I get an "unable to delete features" error.

I CAN query the featureservice (utilizing json and getting features back in my response).

I have set modify permissions on arcgiswebservices and arcgissoc for every folder and database I can think of (and set privileges).  I registered the featureclass as versioned.  I have impersonation=false.  There is a separate apppool for arcgiswebservices.   I think I have it set up correctly...if I didn't would I be able to delete a feature from the services directory??

The only thing I can think of is that we have our gis on one web server, and access it through another.  So, the web address for our website is mywebserver2, and the post goes to our gis server at mywebserver.  We therefore have an "Internet Guest Account" set up.  Not sure what really needs to be done with this, if anything??  I have tried to grant the user "agsadmin" rights--just to test--to no avail.  Everything else on the website seems to work, so I can't imagine that this is the issue.  Thought I would throw it out there, though.

Anyone have any ideas why this would work in the services directory but not through REST?  Suggestions on the best way to make the call besides "window.open"?  (I was trying to find the most straight-forward way to do it).

Please help!!



If you need it, here is the link to the post I was trying to get answers from:  http://forums.arcgis.com/threads/45794-Unable-to-apply-edits?p=164742#post164742
0 Kudos
1 Solution

Accepted Solutions
RaviNarayanan
Esri Contributor
However, if I use the same url: window.open("myservice/ArcGIS/rest/services/folder/myfeatserv/FeatureServer/0/deleteFeatures?objectIds=6&where=&geometry=&geometryType=esriGeometryEnvelope&inSR=&spatialRel=esriSpatialRelIntersects&f=html");
I get an "unable to delete features" error.


You seem be to sending the request using HTTP GET. Editing operations support HTTP POST only. Can you please make sure that the request is using POST instead of GET?

View solution in original post

0 Kudos
5 Replies
RaviNarayanan
Esri Contributor
Hello,
Have you had a chance to look at this editing sample? This sample shows example of how to add and delete features.
http://help.arcgis.com/en/webapi/javascript/arcgis/help/jssamples_start.htm#jssamples/ed_default_edi...
0 Kudos
LisaT
by
Occasional Contributor III
Hi Ravi, thanks for your response.  I am actually utilizing the REST API as outlined here: http://sampleserver3.arcgisonline.com/ArcGIS/SDK/REST/index.html as opposed to dojo.  I wish we were utilizing dojo, but unfortunately the decision was made to internalize the library.  Do you have any suggestions for the ArcGis Server link way of doing things?  It seems as if the V3 library has not been updated for featureserver functions, so I am making my own calls via the http addresses with parameters (as I outline above).  Queries work, edits don't.  However, I CAN edit via the services directory.  What am I doing wrong??
0 Kudos
RaviNarayanan
Esri Contributor
However, if I use the same url: window.open("myservice/ArcGIS/rest/services/folder/myfeatserv/FeatureServer/0/deleteFeatures?objectIds=6&where=&geometry=&geometryType=esriGeometryEnvelope&inSR=&spatialRel=esriSpatialRelIntersects&f=html");
I get an "unable to delete features" error.


You seem be to sending the request using HTTP GET. Editing operations support HTTP POST only. Can you please make sure that the request is using POST instead of GET?
0 Kudos
LisaT
by
Occasional Contributor III
Hi Ravi, I have adjusted my code and have finally gotten deletes to work!  Both deletefeatures and applyedits with a 'deletes' parameter works.  However, I cannot get updates or adds to work.  If I use applyedits in the same way as I use deletes, but instead pass an 'adds' or 'updates' parameter...nothing happens.  To make sure the data is in the correct format, I actually do a 'query', then use the attributes and geometry returned to pass into 'updates' (after changing an attribute).  I also use the geometry returned to pass into adds, with changed attributes (and NOT passing in OBJECTID).  When looking in Firefox, I get the following as (for an add):


POST mywebserver/ArcGIS/rest/services/myfeatserc/FeatureServer/0/applyEdits

(in the POST tab)
Parameters: application/x-www-form-urlencoded
           adds: [{geometry:[{x:-101.7599999997887,y:33.880000000046806, spatialReference:{wkid:4326}}], attributes:{ChngAtt:whatever}}]
                f: json
Source:
adds=%5B%7Bgeometry%3A%5B%7Bx%3A-101.7599999997887%2Cy%3A33.880000000046806%2C%20spatialReference%3A%7Bwkid%3A4326%7D%7D%5D%2C%20attributes%3A%7BStation_Na%3Awhatever%7D%7D%5D&f=json



I am using the same method to post as I do with delete, so I get THE SAME in firefox with a delete...except there is not an "adds" parameter, there is a "deletes" with an objectid listed.  I am only selecting one feature to update/add at this time so that the URL does not get too long.  To test, I have also tried sending parameters:  [{geometry:[{x:-101.7599999997887,y:33.880000000046806}], attributes:{ChngAtt:whatever}}]  (no spatialReference)  and    [{geometry:{x:-101.7599999997887,y:33.880000000046806}, attributes:{ChngAtt:whatever}}]  (no brackets around x & y). 

Any suggestions as to what the applyedits method is looking for??
0 Kudos
LisaT
by
Occasional Contributor III
Got it!  My text was getting converted and no quotes were being sent.  So, the new value "whatever" above did not have quotes.  This caused the update/add to fail.  Changed the code to make sure these are added, and everything works now!  Oh, also have to take out the spatialReference part of the geometry.  These are just points, but it should get me started.  Thanks for your help, Ravi!
0 Kudos