FRAMES | NO FRAMES Description | Parameters | Examples | Response
Apply Edits (Operation)
URL http://<featureservice-url>/applyEdits (POST only)
Parent Resource Feature Service
Required Capability Create,Update,Delete //Create required to add features, Update required to update features and Delete required for deleting features.

Description

This operation is supported from 10.1 onwards.

This apply edits 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 are arrays of edit results for each layer/table edited. Each edit result identifies a single feature on a layer or table 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 query parameters defined in the parameters table below.

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 (and the global id, if available) of the feature along with the other attributes:
"attributes" : {
  "OBJECTID" : 37,
  "OWNER" : "Joe Smith",
  "VALUE" : 94820.37,
  "APPROVED" : true,
  "LASTUPDATE" : 1227667627940
}

Syntax: 
[
{ "id" : <layerId1>,
    "adds" : [<feature1>, <feature2>],
    "updates" : [<feature1>, <feature2>],
    "deletes" : [<objectID1>, <objectID2>]
},
{ "id" : <layerId2>,
    "adds" : [<feature1>, <feature2>],
    "updates" : [<feature1>, <feature2>],
    "deletes" : [<objectID1>, <objectID2>]
}  
]
Example:
[
    {
         "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 
        ] 
    } 
] 
gdbVersion Description: GeoDatabase version to apply the edits. This parameter applies only if hasVersionedData property of the service and isDataVersioned property of the layer(s) edited are true.
If this is not specified, edits are made to published map’s version.

Syntax:
version=<version>
Example:
version=sde.default
rollbackOnFailure Description: Optional parameter to specify if the edits should be applied only if all submitted edits succeed. If false, server will keep the edits that succeed even if some of the submitted edits fail. If true, server will keep 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 can be set to true or false on edit operations.

Syntax: rollbackOnFailure=true|false

Example: rollbackOnFailure=true

Example Usage

Example 1: Apply edits on a feature service resource
http://servicesbeta2.esri.com/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,
    "success": true
   },
   {
    "success": false,
    "error": {
     "code": -2147217395,
     "description": "Setting of Value for depth failed."
    }
   }
  ],
  "updateResults": [
   {
    "objectId": 50,
    "success": true
   }
  ],
  "deleteResults": [
   {
    "objectId": 19,
    "success": true
   },
   {
    "objectId": 23,
    "success": true
   }
  ]
 },
 {
  "id": 1,
  "deleteResults": [
   {
    "objectId": 34,
    "success": true
   },
   {
    "objectId": 44,
    "success": true
   }
  ]
 }
]