Apply Edits (Feature Service)
- URL:https://<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
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.
Starting at version 10.6, services can be published form enterprise geodatabase layers that have attribute rules. Attribute rules are applied to the back end datasets and fire when edits are applied. Types of attribute rules include calculation rules which automatically apply a calculated value to a field as well as constraint rules which will cause an edit to return an error if the constraint is violated. See the constraint rule violate JSON response examples below.
Starting at 10.6.1, functionality has been added to support splitting features. The split operation can be combined with adds, updates, and deletes if needed. See the JSON example below for the split syntax and a response example.
Hosted feature services support adding or updating blob column values in Base64.
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 and edits to be applied. Edits cannot be from a mix of non-versioned and traditional versioned layers or a mix of non-versioned and branch versioned layers. Edits to non-versioned layers must be applied separately from edits to traditional versioned or branch versioned layers. 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. If useGlobalIds is true, the features are added while preserving their globalIds. For new features and attachments, the client must generate globalIds. In order for a feature or attachment to be updated or deleted, clients must include its globalId. If useGlobalIds is false (default), globalIds submitted with the features are ignored and new globalids are assigned when features are added. In order for a feature to be updated or deleted, the attributes property of the feature must include the object ID of the feature along with the other attributes. Attachments are not supported as an edit payload when useGlobalIds is false. When using split, the request should contain the id of the layer that contains the feature you want to split, the objectID of the feature to be split, and the geometry used to split the feature. The split operation supports splitting polylines by points and polygons by polylines. To use split, "supportsRollbackOnFailureParameter": true must be present on the layer and rollbackOnFailure needs to be true when the edit is performed. See the JSON example below for an example.
Syntax:
Example:
Syntax (when useGlobalIds is true) :
Example (when useGlobalIds is true) :
|
gdbVersion | This option was added at 10.1. Description: The geodatabase version to apply the edits. This parameter applies only if the isDataVersioned property of the layer is true. Can be either a traditional version or a branch version. If the gdbVersion parameter is not specified, edits are made to the published map’s version. Syntax: gdbVersion=<version> Example: gdbVersion=SDE.DEFAULT |
honorSequenceOfEdits | This option was added at 10.5 and works with ArcGIS Server services only. Description: Optional parameter specifying whether to apply edits in the order they are submitted in the JSON. If honorSequenceOfEdits = true, edits will apply in the submitted order. If honorSequenceOfEdits = false, which is the default, edits will apply in ascending layer-ID order. All the edits for the layer with the lowest ID will apply first. Values: true|false |
returnEditMoment | This option was added at 10.5 and works with ArcGIS Server services only. Description: Optional parameter specifying whether the response will report the time edits were applied. If returnEditMoment = true, the server will return the time edits were applied in the response's editMoment key. Values: true|false Example: returnEditMoment=true |
rollbackOnFailure | This option was added at 10.1. Description: Optional parameter that specifies whether 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 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, the rollbackOnFailure parameter value will be honored on edit operations. Note: supportsRollbackOnFailureParameter will always be true if the data published is non-versioned, or non-versioned with archiving enabled and does not have composite relationships or attachments. Values: true|false Example: rollbackOnFailure=true |
useGlobalIds | This option was added at 10.4 Description: Optional parameter which is false by default. Requires the service's supportsApplyEditsWithGlobalIds property to be true. When set to true, the features and attachments in the adds, updates, deletes, attachments/adds, attachments/updates, and attachments/deletes for all the layers in the edits parameter are identified by their globalIds. When true, the service adds the new features and attachments while preserving the globalIds submitted in the payload. If the globalId of a feature (or an attachment) collides with a pre-existing feature (or an attachment), that feature and/or attachment add fails. Other adds, updates, or deletes are attempted if rollbackOnFailure is false. If rollbackOnFailure is true, the whole operation fails on any failure including a globalId collision. When useGlobalIds is true, updates or deletes are identified by each feature or attachment globalId rather than their objectId or attachmentId. Values: true|false Example: useGlobalIds=true |
trueCurveClient | This option was added at 10.5 Description: Optional parameter which is false by default is set by client to indicate to the server that client in true curve capable. When set to true by client, indicates to the server that true curves geometries should be downloaded from and that geometries containing true curves should be consumed by the feature service, without converting curves to densified polylines or polygons. When set to false by client, indicates to the server that client is not true curves capable and hence, curves are converted to densified polylines or polygons. Values: true|false Example: trueCurveClient=true |
sessionID | This option was added at 10.6 Description: Optional parameter which is set by a client during long transaction editing on a branch version. The sessionID is a guid value that clients establish at the beginning and use throughout the edit session. The sessonID ensures isolation during the edit session. Syntax: sessionID=<sessionID> Example: sessionID={E81C2E2D-C6A7-40CB-BF61-FB499E53DD1D} |
usePreviousEditMoment | This option was added at 10.6 Description: Optional parameter which is set by a client during long transaction editing on a branch version. The usePreviousEditMoment parameter is used to apply the edits with the same edit moment as the previous set of edits. This allows an editor to apply single block of edits partially, complete another task and then complete the block of edits. When set to true, the edits are applied with the same edit moment as the previous set of edits.. When set to false or not set (default) the edits are applied with a new edit moment. Values: true|false Example: usePreviousEditMoment=true |
returnServiceEditsOption | This option was added at 10.6 Description: Optional parameter that returns features edited due to the geodatabase behavior that results from applying the edits. For example, if a feature is deleted and it is the origin in a composite relationship, the destination feature is automatically deleted in the geodatabase. If returnServiceEditsOption is set to originalAndCurrentFeatures, the deleted destination feature is returned along with a reference to the deleted origin feature in the response. Note that even for deletes, the geometry and attributes of the edited feature are returned. Results returned from applyEdits are organized in a layer by layer fashion. If returnServiceEditsOption is set to originalAndCurrentFeatures, each layer may have edited features returned in an editedFeatures object. Service-level applyEdits response structure :
The editedFeatures object returns full features including the original features prior to delete, the original and current features for updates and the current rows for inserts which may contain implicit changes (e.g. as a result of a calculation rule). editedFeatures response structure :
The response includes no editedFeatures and exceededTransferLimit = true if the count of edited features to return is more than the maxRecordCount. If clients are using this parameter to maintain a cache, they should invalidate the cache when exceededTransferLimit = true is returned. If the server encounters an error when generating the list of edits is the response, exceededTransferLimit = true is also returned. The originalAndCurrentFeatures option is only valid when rollBackOnFailure is true. Edited features are returned in the spatial reference of the feature service as defined by the services spatialReference object or by the spatialReference of the layers extent object. The default for this parameter is none which will not include editedFeatures. Values: none|originalAndCurrentFeatures Example: returnServiceEditsOption=originalAndCurrentFeatures |
Example Usage
Example 1: Apply edits on a feature service resource:
https://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
]
}
]
Example 2: Adding a feature and attachment in one call with useGlobalIds is true:
[
{
"id": 0,
"adds": [
{
"geometry": {
"x": -118.15,
"y": 33.80
},
"attributes": {
"OWNER": "Joe Smith",
"GlobalID": "{74100804-E229-49b8-8CDC-9B5D3EF03EDA}",
"VALUE": 94820.37,
"APPROVED": true,
"LASTUPDATE": 1227663551096
}
}
],//endofadds"
attachments": {
"adds": [
{
"globalId": "{55E85F98-FBDD-4129-9F0B-848DD40BD911}",
"parentGlobalId": "{74100804-E229-49b8-8CDC-9B5D3EF03EDA}",
"contentType": "image/pjpeg",
name":"Pothole.jpg",
"uploadId" : {DD1D0A30-CD6E-4ad7-A516-C2468FD95E5E}"
}
]//endofattachments/adds
}//endofattachments
}//endoflayer
]//endofedits
Response:
[
{
"id": 0,
"addResults": [
{
"objectId": 1000,
"globalId": "{74100804-E229-49b8-8CDC-9B5D3EF03EDA}",
"success": true
}
],
"attachments": {
"addResults": [
{
"objectId": 2000,
"globalId": "{55E85F98-FBDD-4129-9F0B-848DD40BD911}",
"success": true
}
]
}
}
]
Example 3: Adding features and a relationship between them in one call with useGlobalIds is true:
Let us assume the service has a Parcel layer (id: 0) and Owner table (id: 1). Parcel is the Origin Class and Owner is the Destination Class. The Parcel's globalID is related to Owner's parcelguid field, which makes parcelguid a foreign key field. An editor wants to add a parcel and an owner and have them related in one applyEdits call:
[
{"id" : 0,
"adds" :
[
{"geometry" : <Parcel polygon geometry>,
"attributes" : {"Name" : "Donut Hole",
"Neighborhood": "North Redlands",
"GlobalID": "{74100804-E229-49b8-8CDC-9B5D3EF03EDA}"
}
}
],
}//end of layer 0
{"id" : 1,
"adds" :
[
{
"attributes" : {"Name" : "John Smith ",
"GlobalID": "{EFC28461-50EC-4193-82A8-7C46CF34E613}",
"ParcelGuid":"{74100804-E229-49b8-8CDC-9B5D3EF03EDA}"
}
}
],
}//end of layer 1
The service will add a parcel to Parcel layer (id: 0) and an owner record to Owner table (id: 1). They will be related because of identical values for the parcel's globalID and the owner's parcelguid.
Response:
[
{
"id": 0,
"addResults": [
{
"objectId": 2000,
"globalId": "{74100804-E229-49b8-8CDC-9B5D3EF03EDA}",
"success": true
}
]
},
{
"id": 1,
"addResults": [
{
"objectId": 3000,
"globalId": "{EFC28461-50EC-4193-82A8-7C46CF34E613}",
"success": true
}
]
}
]
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>",
}
}
],
"splitResults": [
{
"objectId": <objectId>,
"results": [ <objectId>, <objectId1>
// Split returns the objectId of the original feature and the feature(s) created from the split
]
}
],
"attachments": {
"addResults": [],
"updateResults": [],
"deleteResults": []
},
},
{
"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>",
}
}
],
"splitResults": [
{
"objectId": <objectId>,
"results": [ <objectId>, <objectId1>, <objectId2>
// Split returns the objectId of the original feature and the feature(s) created from the split
]
}
],
"attachments": {
"addResults": [],
"updateResults": [],
"deleteResults": []
},
}
]
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
}
]
}
]
JSON response example (where edits are made using split)
[
{
"id": 0,
"splitResults": [
{
"objectId": 11,
"results": [
11,
56
]
}
]
},
{
"id": 1,
"splitResults": [
{
"objectId": 23,
"results": [
23,
54,
53,
52,
55,
56
]
}
]
}
]
JSON response example (where returnEditMoment and useGlobalids are true, and attachments are included)
[
{
"id": 0,
"editMoment" : 1457994488000,
"addResults": [
{
"objectId": 618,
"globalId": "{74100804-E229-49b8-8CDC-9B5D3EF03EDA}",
"success": true
},
{
"objectId": 619,
"globalId": "{39B856DC-AFE4-4c02-B433-A9361ACD91CF}",
"success": true
}
],
"updateResults": [
{
"objectId": 50,
"globalId": "{1A9F8368-F9BB-428B-BB03-F45724362DB5}",
"success": true
},
{
"objectId": 51,
"globalId": "{6CE34136-EC3A-40D7-80BF-E1D9BE33812A}",
"success": true
}
],
"deleteResults": [
{
"objectId": 25,
"globalId": "{0A196F7B-44A6-4EE8-94C0-4417EA3B0841}",
"success": true
},
{
"objectId": 26,
"globalId": "{C2746F2C-80E5-4506-B51F-3B7B134BC58B}",
"success": true
}
],
"attachments": {
"addResults": [
{
"objectId": 500,
"globalId": "{55E85F98-FBDD-4129-9F0B-848DD40BD911}",
"success": true
},
{
"objectId": 501,
"globalId": "{3373EE9A-4619-41B7-918B-DB54575465BB}",
"success": true
}
],
"updateResults": [
{
"objectId": 600,
"globalId": "{8FDD9AEF-E05E-440A-9426-1D7F301E1EBA}",
"success": true
},
{
"objectId": 600,
"globalId": "{6CE34136-EC3A-40D7-80BF-E1D9BE33812A}",
"success": true
}
],
"deleteResults": [
{
"objectId": 800,
"globalId": "{95059311-741C-4596-88EF-C437C50F7C00}",
"success": true
},
{
"objectId": 801,
"globalId": " {18F43B1C-2754-4D05-BCB0-C4643C331C29}",
"success": true
}
]
}
},
{
"id": 1,
"editMoment" : 1457994488000,
"deleteResults": [
{
"objectId": 25,
"globalId": "{8BCB622B-E45D-4A09-8BAC-1D8735E9625F}",
"success": true
},
{
"objectId": 26,
"globalId": "{D44DFB67-C66B-45EA-B24C-FF4632C8081D}",
"success": true
}
]
}
]
JSON response example (where a constraint rule is violated and rollBackOnFailure is true)
{
"error": {
"code": 400,
"extendedCode": -2147207418,
"message": "Unable to complete operation.",
"details": [
"Violated attribute constraint rule. [Error No: -1, ]",
"Operation rolled back."
]
}
}
JSON response example (where a constraint rule is violated and rollBackOnFailure is false)
[
{
"id": 1,
"updateResults": [
{
"objectId": 2,
"globalId": "{B703ACAC-A1A8-4F49-BB19-1E684A67A265}",
"success": false,
"error": {
"code": 1019,
"extendedCode": -2147207418,
"description": "Violated attribute constraint rule. [Error No: -1, ]"
}
},
{
"objectId": 1,
"globalId": "{2FACC38A-3E3E-43A5-A6EB-BC9075407EC8}",
"success": true
}
]
}
]
JSON response example (returnServiceEditsOption = originalAndCurrentFeatures and an origin feature is deleted)
[
{
"id": 9,
"deleteResults": [
{
"objectId": 18,
"globalId": "{8ED93567-DC83-4DDA-837C-467C0138B22A}",
"success": true
}
],
"editedFeatures": {
"deletes": [
{
"attributes": {
"STATE_NAME": "Connecticut",
"STATE_FIPS": "09",
"SUB_REGION": "N Eng",
"POP1996": 3287604,
"CALC_INT": null,
"GLOBALID": "{8ED93567-DC83-4DDA-837C-467C0138B22A}",
"reprowid": 13,
"OBJECTID": 18
},
"geometry": {
"rings": [
[
[
-8185413.79680000059,
5089741.03199999779
],
[
-8183939.36889999919,
5111017.59870000184
],
[
-8180275.50779999979,
5168072.90540000051
],
[
-8131452.56310000084,
5166406.08200000226
],
[
-8127051.54419999942,
5166360.96440000087
],
[
-8105941.36580000073,
5165985.82320000231
],
[
-8106078.06100000069,
5160543.51210000366
],
[
-8100500.73489999957,
5161289.78400000185
],
[
-8099200.41330000013,
5166036.78519999981
],
[
-8082907.47210000083,
5165540.56889999658
],
[
-8082718.00349999964,
5164381.11180000007
],
[
-8079832.93239999935,
5164202.194600001
],
[
-8078643.93569999933,
5165478.81440000236
],
[
-8071558.22189999931,
5165574.73600000143
],
[
-8030234.64900000021,
5164920.73650000244
],
[
-8025628.91169999912,
5164830.51550000161
],
[
-7993054.0493999999,
5163658.11640000343
],
[
-7992552.10989999957,
5161605.117899999
],
[
-7991485.33699999936,
5119352.91860000044
],
[
-7991970.35720000044,
5107451.891900003
],
[
-7991701.96639999934,
5101428.2324000001
],
[
-7993099.02050000057,
5073856.45130000263
],
[
-7997913.70610000007,
5072079.04389999807
],
[
-7996897.91599999927,
5062897.7154000029
],
[
-7998111.62570000067,
5060434.7949000001
],
[
-8000216.125,
5060052.50919999927
],
[
-8046383.31760000065,
5053884.94259999692
],
[
-8051385.68979999982,
5055143.42369999737
],
[
-8057180.42390000075,
5065327.90179999918
],
[
-8057151.59359999932,
5053434.03989999741
],
[
-8073747.76750000007,
5051301.10679999739
],
[
-8115991.06409999914,
5052243.47439999878
],
[
-8137996.47829999961,
5036109.59520000219
],
[
-8199079.04629999958,
5012090.14180000126
],
[
-8199142.71859999932,
5014188.5
],
[
-8207103.17620000057,
5027140.92450000346
],
[
-8179595.24080000073,
5043463.61529999971
],
[
-8187625.27009999938,
5055733.52480000257
],
[
-8186961.13519999944,
5066359.28899999708
],
[
-8185413.79680000059,
5089741.03199999779
]
]
]
}
}
]
}
},
{
"id": 7,
"editedFeatures": {
"deletes": [
{
"attributes": {
"CITY_FIPS": "37000",
"CITY_NAME": "Hartford",
"STATE_FIPS": "09",
"STATE_NAME": "Connecticut",
"STATE_CITY": "0937000",
"TYPE": "city",
"ELEVATION": 99,
"ADATE": null,
"GLOBALID": "{405FB3AC-2E9C-4929-A2B9-15550C3D95B4}",
"AGUID": "{8ED93567-DC83-4DDA-837C-467C0138B22A}"
"reprowid": 12,
"OBJECTID": 710
},
"geometry": {
"x": -8091131.2201000005,
"y": 5125946.99199999869
}
}
]
}
}
]