How to edit a feature service table using esri/request in 4.x?

311
1
07-26-2019 07:51 AM
DavidWilson3
Occasional Contributor

I am trying to figure out how I would go about do basic CRUD on a feature service table using esri/request in 4.x and any example code would be greatly appreciated.  

0 Kudos
1 Reply
VictorTey
Esri Contributor

Hi, I do not have the code handy however you will need to use the rest add-feature endpoint

I imagine it will be something like the following. Note code below are untested

You can also open your developer tool in chrome and hit the addfeature endpoint, set f=json to see exactly how you should be parsing the request and replicate that in esriRequest.

https://developers.arcgis.com/rest/services-reference/add-features.htm

var data = [
  {
    "geometry" : {"x" : -118.15, "y" : 33.80}, 
    "attributes" : {
      "OWNER" : "Joe Smith",
      "VALUE" : 94820.37,
      "APPROVED" : true,
      "LASTUPDATE" : 1227663551096
    }
  },
  {
    "geometry" : { "x" : -118.37, "y" : 34.086 }, 
    "attributes" : {
      "OWNER" : "John Doe",
      "VALUE" : 17325.90,
      "APPROVED" : false,
      "LASTUPDATE" : 1227628579430
    }
  }
]

var url = "https://abc/ArcGIS/rest/services/xxx//FeatureServer/0/addFeature "

esriRequest(, {
  responseType: "json",

   method:"post",

   body:JSON.stringify(data)
}).then(function(response){
 
});