FRAMES | NO FRAMES Description | Parameters | Examples | Response
Apply Edits (Operation)
URL http://<featurelayer-url>/applyEdits (POST only)
Parent Resource Layer

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 result of this operation are 3 arrays of edit results (for adds, updates and deletes respectively). Each edit result identifies a single feature and indicates if the edit were successful or not. If not, it also includes an error code and an error description.

You can provide arguments to the query 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
adds Description: The array of features to be added. The structure of each feature in the array is 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 the geometry.

Syntax: Example:
[
  {
    "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
    }
  }
]
updates Description: The array of features to be updated. The structure of each feature in the array is 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 (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
}
Features to be updated to a feature layer should include the geometry.

Records to be added to a table should not include the geometry.

Syntax: Example:
[
  {
    "geometry" : {"x" : -118.15, "y" : 33.80},  
    "attributes" : {
      "OBJECTID" : 37
      "OWNER" : "Joe Smith",
      "VALUE" : 94820.37,
      "APPROVED" : true,
      "LASTUPDATE" : 1227667627940
    }
  },
  {
    "geometry" : { "x" : -118.37, "y" : 34.086 },  
    "attributes" : {
      "OBJECTID" : 462
      "OWNER" : "John Doe",
      "VALUE" : 17325.90,
      "APPROVED" : false,
      "LASTUPDATE" : 9269154204840
    }
  }
]
deletes Description: The object IDs of this layer / table to be deleted.

Syntax: deletes=<objectId1>, <objectId2>

Example: deletes=37, 462

Example Usage

Example 1: TODO

JSON Response Syntax

{
  "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

{
  "addResults" : [
    {
      "objectId" : 37,
      "globalId" : null,
      "success" : true
    },
    {
      "objectId" : -1,
      "globalId" : null,
      "success" : false,
      "error" : {
        "code" : 50,
        "description" : "Cannot add unapproved parcels.",
      }
    }
  ],
  "updateResults" : [
    {
      "objectId" : 463,
      "globalId" : null,
      "success" : true
    },
    {
      "objectId" : 462,
      "globalId" : null,
      "success" : false,
      "error" : {
        "code" : 30,
        "description" : "'LASTUPDATED' date cannot be in the future.",
      }
    }
  ],
  "deleteResults" : [
    {
      "objectId" : 9,
      "globalId" : null,
      "success" : true
    },
    {
      "objectId" : 625,
      "globalId" : null,
      "success" : false,
      "error" : {
        "code" : 60,
        "description" : "Features whose last update was less than 2 days ago cannot be deleted.",
      }
    }
  ]
}