Apply Edits (Feature Service)
- URL:http://<featureservice-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.1
Description
This operation is supported at 10.1 and later.
The applyEdits operation applies edits to features associated with multiple layers or tables in a single call (POST only). This operation is performed on a feature service resource. The result of this operation is an array of edit results for each layer/table edited. Each edit result identifies a single feature on a layer or table and indicates whether the edits were successful or not. If an edit is not successful, the edit result also includes an error code and an error description.
You can provide arguments to the applyEdits operation as defined in the following parameters table:
Request parameters
Parameter |
Details |
---|---|
f |
Description: The response format. The default response format is html. Values: html | json |
edits | Description: The array of layers to be edited. Features to be added or updated to a feature layer should include the geometry. Records to be added or updated to a table should not include the geometry. For features that are updated, the attributes property of the feature should include the object ID of the feature along with the other attributes:
Syntax:
Example:
|
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
Apply edits on a feature service resource:
http://services.myserver.com/lidGgNLxw9LL0SbI/ArcGIS/rest/services/PoolPermits/FeatureServer/applyEdits
Sample input for adds, represented by an array of features:
[
{
"id" : 0,
"adds" : [
{
"geometry" : {
"x": -143.501,
"y": 57.043000000000006
},
"attributes" : {
"datetime" : 1272210710000,
"depth" : 31.100000000000001,
"region" : "Andreanof Islands, Aleutian Islands, Alaska"
}
},
{
"geometry" : {
"x" : -72.865099999999927,
"y" : -37.486599999999953
},
"attributes" : {
"datetime" : 1272210142999,
"depth" : "40.x",
"region" : "Bio-Bio, Chile"
}
}
],
"updates" : [
{
"geometry" : {
"x" : -149.450,
"y" : 60.120
},
"attributes" : {
"OBJECTID" : 50,
"datetime" : 1272210710000,
"region" : "Andreanof Islands, Aleutian Islands, Alaska"
}
}
],
"deletes" : [
19,23
]
},
{
"id" : 1,
"deletes" : [
34,44
]
}
]
JSON response syntax
[
{
"id" : <layerId1>,
"addResults" : [
{
"objectId" : <objectId1>,
"globalId" : <globalId1>,
"success" : <true | false>,
"error" : { //only if success is false
"code" : <code1>,
"description" : "<description1>",
}
},
{
"objectId" : <objectId2>,
"globalId" : <globalId2>,
"success" : <true | false>,
"error" : { //only if success is false
"code" : <code2>,
"description" : "<description2>",
}
}
],
"updateResults" : [
{
"objectId" : <objectId1>,
"globalId" : <globalId1>,
"success" : <true | false>,
"error" : { //only if success is false
"code" : <code1>,
"description" : "<description1>",
}
},
{
"objectId" : <objectId2>,
"globalId" : <globalId2>,
"success" : <true | false>,
"error" : { //only if success is false
"code" : <code2>,
"description" : "<description2>",
}
}
],
"deleteResults" : [
{
"objectId" : <objectId1>,
"globalId" : <globalId1>,
"success" : <true | false>,
"error" : { //only if success is false
"code" : <code1>,
"description" : "<description1>",
}
},
{
"objectId" : <objectId2>,
"globalId" : <globalId2>,
"success" : <true | false>,
"error" : { //only if success is false
"code" : <code2>,
"description" : "<description2>",
}
}
]
},
{
"id" : <layerId2>,
"addResults" : [
{
"objectId" : <objectId1>,
"globalId" : <globalId1>,
"success" : <true | false>,
"error" : { //only if success is false
"code" : <code1>,
"description" : "<description1>",
}
},
{
"objectId" : <objectId2>,
"globalId" : <globalId2>,
"success" : <true | false>,
"error" : { //only if success is false
"code" : <code2>,
"description" : "<description2>",
}
}
],
"updateResults" : [
{
"objectId" : <objectId1>,
"globalId" : <globalId1>,
"success" : <true | false>,
"error" : { //only if success is false
"code" : <code1>,
"description" : "<description1>",
}
},
{
"objectId" : <objectId2>,
"globalId" : <globalId2>,
"success" : <true | false>,
"error" : { //only if success is false
"code" : <code2>,
"description" : "<description2>",
}
}
],
"deleteResults" : [
{
"objectId" : <objectId1>,
"globalId" : <globalId1>,
"success" : <true | false>,
"error" : { //only if success is false
"code" : <code1>,
"description" : "<description1>",
}
},
{
"objectId" : <objectId2>,
"globalId" : <globalId2>,
"success" : <true | false>,
"error" : { //only if success is false
"code" : <code2>,
"description" : "<description2>",
}
}
]
}
]
JSON response example
[
{
"id": 0,
"addResults": [
{
"objectId": 617,
"globalId" : "{be6557a4-2204-4a66-a901-7295080003a6}",
"success": true
},
{
"success": false,
"error": {
"code": -2147217395,
"description": "Setting of Value for depth failed."
}
}
],
"updateResults": [
{
"objectId": 50,
"globalId" : "{09b3b932-a75c-4438-837e-9a17f84113d5}",
"success": true
}
],
"deleteResults": [
{
"objectId": 19,
"success": true
},
{
"objectId": 23,
"success": true
}
]
},
{
"id": 1,
"deleteResults": [
{
"objectId": 34,
"success": true
},
{
"objectId": 44,
"success": true
}
]
}
]