Apply Edits (Feature Service\Layer)
- URL:http://<featurelayer-url>/applyEdits(POST only)
- Required Capability:Create,Update,Delete //Create required to add features, Update required to update features, and Delete required to delete features.
- Version Introduced:10.0
Description
This operation adds, updates and deletes features to the associated feature layer or table in a single call (POST only). The apply edits operation is performed on a feature service layer resource.
The operation returns the results of the edits. The results are grouped by type of edit (addResults, updateResults, and deleteResults). Each contains an array of edit result objects. Each edit result identifies a single feature and indicates if the edits were successful or not. If not, it also includes an error code and an error description.
You can provide arguments to the Apply Edits operation as defined in the parameters table below.
Request Parameters
Parameter |
Details |
---|---|
f |
Description: The response format. The default response format is html. Values: html | json |
adds | Description: The array of features to be added. The structure of each feature in the array is the same as the structure of the json feature object returned by the ArcGIS REST API. Features to be added to a feature layer should include the geometry. Records to be added to a table should not include geometry. Syntax: [<feature1>, <feature2>] Example:
|
updates | Description: The array of features to be updated. The structure of each feature in the array is the same as the structure of the json feature object returned by the ArcGIS REST API. The attributes property of the feature should include the object id of the feature along with the other attributes:
Records to be added to a table should not include geometry. Syntax: [ <feature1>, <feature2> ] Example:
|
deletes | Description: The object IDs of the features/records to be deleted. Syntax: deletes=<objectId1>, <objectId2> Example: deletes=37, 462 |
gdbVersion | //This option was added at 10.1 Description: Geodatabase version to apply the edits. This parameter applies only if the isDataVersioned property of the layer is true. If the gdbVersion parameter is not specified, edits are made to the published map’s version. Syntax: gdbVersion=<version> Example: gdbVersion=SDE.DEFAULT |
rollbackOnFailure | //This option was added at 10.1 Description: Optional parameter to specify if the edits should be applied only if all submitted edits succeed. If false, the server will apply the edits that succeed even if some of the submitted edits fail. If true, the server will apply the edits only if all edits succeed. The default value is true. Not all data supports setting this parameter. Query the supportsRollbackonFailureParameter property of the layer to determine whether or not a layer supports setting this parameter. If supportsRollbackOnFailureParameter = false for a layer, then when editing this layer, rollbackOnFailure will always be true, regardless of how the parameter is set. However, if supportsRollbackonFailureParameter = true, this means the rollbackOnFailure parameter value will be honored on edit operations. Values: true|false Example: rollbackOnFailure=true |
Example Usage
Example 1: Add an array of features using the apply edits operation on a feature service layer resource
http://services.myserver.com/ERmEceOGq5cHrItq/ArcGIS/rest/services/SanFrancisco/311Incidents/FeatureServer/0/applyEdits
sample input for adds, represented by an array of features:
[
{
"attributes" : {
"req_id" : "508389",
"req_type" : "Graffiti Complaint - Public Property",
"req_date" : "09\/19\/2009",
"req_time" : "18:44",
"address" : "11TH ST and HARRISON ST",
"x_coord" : "6008925.0",
"y_coord" : "2108713.8",
"district" : "6",
"status" : 1
},
"geometry" : {
"x" : -122.41247978999991,
"y" : 37.770630098000083
}
},
{
"attributes" : {
"req_id" : "508395",
"req_type" : "Graffiti Complaint - Public Property",
"req_date" : "09\/19\/2009",
"req_time" : "19:01",
"address" : "13TH ST and MANCHESTER ST",
"x_coord" : "6008929.0",
"y_coord" : "2108713.9",
"district" : "6",
"status" : 1
},
"geometry" : {
"x" : -121.42248867898987,
"y" : 38.790630098000452
}
}
]
Example 2: Update an array of features using the apply edits operation on a feature service layer resource
http://services.myserver.com/ERmEceOGq5cHrItq/ArcGIS/rest/services/SanFrancisco/311Incidents/FeatureServer/0/applyEdits
sample input for updates, represented by an array of features:
[
{
"attributes" : {
"objectid": 1234567
"req_id" : "508389",
"req_type" : "Graffiti Complaint - Private Property",
"req_date" : "09\/19\/2009",
"req_time" : "18:44",
"address" : "11TH ST and HARRISON ST",
"x_coord" : "6008925.0",
"y_coord" : "2108713.8",
"district" : "6",
"status" : 2
},
"geometry" : {
"x" : -122.41247978999991,
"y" : 37.770630098000083
}
},
{
"attributes" : {
"req_id" : "508395",
"req_type" : "Graffiti Complaint - Public Property",
"req_date" : "09\/19\/2009",
"req_time" : "19:01",
"address" : "13TH ST and MANCHESTER ST",
"x_coord" : "6008929.0",
"y_coord" : "2108713.9",
"district" : "6",
"status" : 2
},
"geometry" : {
"x" : -121.42248867898987,
"y" : 38.790630098000452
}
}
]
Example 3: Delete features using the apply edits operation on a feature service layer resource
http://services.myserver.com/ERmEceOGq5cHrItq/ArcGIS/rest/services/SanFrancisco/311Incidents/FeatureServer/0/applyEdits
The input for deletes is a list of objectIds of the features to be deleted.
JSON Response Syntax
{
"addResults" : [ <editResult1>}, <editResult2> ],
"updateResults" : [ <editResult1>}, <editResult2> ],
"deleteResults" : [ <editResult1>}, <editResult2> ]
}
JSON Response Example
{
"addResults": [
{
"objectId": 618,
"success": true
},
{
"success": false,
"error": {
"code": -2147217395,
"description": "Setting of Value for depth failed."
}
}
],
"updateResults": [
{
"objectId": 50,
"success": true
}
],
"deleteResults": [
{
"objectId": 25,
"success": true
},
{
"objectId": 26,
"success": true
}
]
}