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

Description

This operation adds features to the associated feature layer or table (POST only). The add features operation is performed on a feature service layer resource. The result of this operation is an array of edit results. 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 add features 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 | pjson
features 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": -82.71,
      "y": 40.14,
      "spatialReference": {
        "wkid": 4326
      }
    },
    "attributes": {
      "FID": 4011,
      "COMMENTS": "Africa&Polaris LC2-2",
      "WATTAGE": 400,
      "OPERATINGVOLTAGE": 60,
      "WORKORDERI": "129908",
      "MANUFACTUR": "GE",
      "POLEHEIGHT": 45
    }
  },
  {
    "geometry": {
      "x": -82.73,
      "y": 40.11,
      "spatialReference": {
        "wkid": 4326
      }
    },
    "attributes": {
      "FID": 4012,
      "COMMENTS": "North&Polaris LC2-2",
      "WATTAGE": 400,
      "OPERATINGVOLTAGE": 60,
      "WORKORDERI": "129933",
      "MANUFACTUR": "GE",
      "POLEHEIGHT": 35
    }
  }
]
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. Default value is false.

Syntax: rollbackOnFailure=true|false

Example: rollbackOnFailure=true

Example Usage

Example 1:  Add an array of features using the add features operation on a feature service layer resource:

http://sampleserver10.arcgisonline.com/arcgis/rest/services/Utilities/FeatureServer/0/addFeatures

Sample input array of features:

[
  {
    "geometry": {
      "x": -82.71,
      "y": 40.14,
      "spatialReference": {
        "wkid": 4326
      }
    },
    "attributes": {
      "FID": 4011,
      "COMMENTS": "Africa&Polaris LC2-2",
      "WATTAGE": 400,
      "OPERATINGVOLTAGE": 60,
      "WORKORDERI": "129908",
      "MANUFACTUR": "GE",
      "POLEHEIGHT": 45
    }
  }
]

 

JSON Response Syntax

{
  "addResults" : [
    {
      "objectId" : <objectId1>,
      "success" : <true | false>,
      "error" : { //only if success is false
        "code" : <code1>,
        "description" : "<description1>",
      }
    },
    {
      "objectId" : <objectId2>,
      "success" : <true | false>,
      "error" : { //only if success is false
        "code" : <code2>,
        "description" : "<description2>",
      }
    }
  ]
}

JSON Response Example

{
  "addResults" : [
    {
      "objectId" : 4011, 
      "success" : true
    }, 
    {
      "objectId" : 4012, 
      "success" : false,
      "error" :
      {
         "code": 1007,
         "description" : "The specified feature could not be inserted."
       }
    }
  ]
}