Skip To Content
ArcGIS Developers
Dashboard

Append (Feature Service/Layer)

Description

ArcGIS Online and ArcGIS Enterprise feature service layers support an append operation, a high-performance API capable of handling large volumes of data that has the ability to upsert data.

Upsert

Upsert is a combination of insert and update, driven by the featureId. Upsert is used to add new features and update existing features at the same time. If a feature in the source data matches an existing feature in the destination layer, the existing feature is updated with the values from the source. If there is no match, a new feature is created based on the values from the source.

The append operation supports featureId of type ObjectId and GlobalId. The target layer must have a destination field of one of these types.

Unique index on source data featureId

The destination objectId or globalId fields do not need to be mapped to source fields of the same data type. The source featureId can map to a different field type, as long as the values can be converted to an acceptable destination value for featureId. For example, the destination globalId can be mapped to the GlobalId, Guid, string field types; the objectId can be mapped to the short or long field types.

Note:

When upsert is set to true, the append operation checks for uniqueness in the source featureId. It is not acceptable to append two source rows to the same destination row, as the append operation would return an error if more than one source feature shares the same featureId.

Enable and disable append capabilities

Feature service Append capabilities must be enabled for the append operation to be used by nonadministrative users. Organization administrators, or the service owner, can use the append operation without having the Append capability enabled on the feature service. The Append capability needs to be added to the service capabilities only if the service owner or organization administrators need to allow nonadministrative users to append data to a feature service. Oragnization administrators or the service owner can enable or disable the Append capability for an existing feature service using the updateDefinition operation. For more information on how to configure Append and other capabilities on a feature service layer, see Update Definition (Feature Service/Layer).

The Append capability does not require any editing capabilities to be enabled. Features will be inserted or updated when upset is set to true through the append operation without the administrator adding either the Create or Update capabilities to the feature service.

Supports append

A feature service layer can return the supportsAppend metadata property. When this property is absent or returns as false, the Append capability cannot be added and the feature service layer does not support the append operation, even for the organization administrators of the feature service owner.

Supported append formats

A feature service that supports append returns the supportedAppendFormats metadata property. This property lists the supported appendUploadFormat values for this operation.

The format are:

  • sqlite: sqlite database
  • gpkg: geopackage
  • shapefile: shapefile
  • filegdb: file geodatabase
  • featureCollection: feature collection
  • geojson: GeoJSON
  • csv: Comma separated values
  • excel: Microsoft Excel format

Sync and Change Tracking

The upsert parameter is not supported if the feature service has sync or changeTracking capabilities enabled. When sync or changeTracking are enabled, the upsert parameter is blocked for the following reasons:

  • The Esri sync engines might not be able to support syncing the changes from the upsert parameter. The append operation might be using a very low level database API that might prevent the use of triggers to track the changes from the upsert parameter. ArcGIS Online feature service sync engines rely on triggers to track the edit changes.
  • The volume of changes from upsert might be quite large for the syncing process, and it will be better for the client to re-create the replica after upsert.
  • Attempting to set the upsert parameter to true will return an error if sync or change tracking are enabled.

Feature service layer views

The append operation can be used to enable feature service layer views.

Preserve featureId

The source featureId (ObjectId or GlobalId) is only preserved when upsert is true. When upsert is false, all new rows created will have their new objectId or globalId allocated by the system.

Feature service metadata

The metadata for a feature service is updated after adding or updating data using the append operation. The extent and lastEditDate of the feature service will be updated.

Spatial references

The source data is projected to the layer spatial reference when appending data to the destination layers. Data from CSV, Geojson, and Excel is defaulted to GCS spatial reference (4326). If the source data from these data sources is in a different spatial reference than 4326, the source spatial reference can be passed in the appendSourceInfo parameter (sourceSR).

Geocoding

In our ArcGIS Online services, the append operation supports geocoding geometry from CSV and Excel data. The cost and billing of geocoding is the same cost and billing of geocoding when publishing data as a feature service.

Editor tracking and ownership-based access control (OBAC)

Editor tracking is supported with feature service append API. The CreationDate and EditDate, Editor, and Creator fields are populated based on the user who is calling append. Editor tracking fields are set when inserting or updating existing features. The creator and the editor fields will be set to the append user.

Service owner and administrators will bypass any OBAC set on the feature service. For nonowners, if allowsUpdateToOthers is set to false on the feature service, the append user can only update their features or the features owned by anonymous users.

Time zone (ArcGIS Online)

Source data timeZoneInfo can be specified in the appendsourceInfo json object similar to the TimeZoneInfo passed in when publishing new feature service.

Example

{"dateFieldsTimeReference": {"timeZone": <"timezone">,"respectDaylightSaving": true}}

Appending multipatch data (ArcGIS Online)

Appending/upserting data to a multipatch feature service is supported. For ArcGIS Online feature services, the client can turn on the Append capability on multipatch feature services using the updateDefinition admin API. Similar to a nonmultipatch feature service, objectId, globalId, or any other fields with a unique index can be used to upsert data to multipatch feature services. The append operation returns an error when a client tries to append nonmultipatch geometry data into a feature service that stores multipatch geometries.

Request parameters

ParameterDetails
sourceTableName

Required only when the source data contains more than one table.

Example

sourceTableName= "Building"
fieldMappings

(Optional)

Used to map source data to a destination layer. The append default behavior is to match by name; the operation tries to find fields in the source data that match the destination fields.

The fieldMappings parameter can be used as an input to define mappings for fields in the source that do not match the destination layer fields. There is no need to define mappings for fields that match the destination layer fields. The default behavior is to match fields by name even if they are not specified in the field mapping parameter. To prevent the default mapping fields behavior, the appendFields parameter can be used with append to restrict the list of fields that will be updated or inserted when using append API.

Syntax

fieldMappings=[{"name": <"targetName">, "sourceName": <"sourceName">}, ...]

Example

fieldMappings=[{"source":"FACILITYID","name":"FACILITYID"},{"source":"FLOW","name":"FLOW"},{"source":"DESC","name":"DESC"}]
edits

Only feature collection json is supported. Append supports all formats through the uploadId.

appendSourceInfo

This is only needed when appending data from Excel or CSV. The appendSourceInfo can be the publishing parameter returned from analyzing the CSV or Excel files. Appending data from the CSV or Excel files requires the appendSourceInfo parameter that identifies the locationType of the geometry in addition to how to parse the content of the CSV and Excel files. The appendSourceInfo parameter is designed to be the same as analyzing publishing parameters returned from analyzing the CSV or Excel files.

{
  "type": "csv",
  "name": "StarbucksClosures",
  "useBulkInserts": true,
  "sourceUrl": "",
  "locationType": "coordinates",
  "maxRecordCount": 1000,
  "latitudeFieldName": "y",
  "longitudeFieldName": "x",
  "columnDelimiter": ",",
  "qualifier": "\"",
  "sourceSR": {
    "wkid": 4326,
    "latestWkid": 4326
  },
  "targetSR": {
    "wkid": 102100,
    "latestWkid":3857
  },
  "editorTrackingInfo": {
    "enableEditorTracking": false,
    "enableOwnershipAccessControl": false,
    "allowOthersToQuery": true,
    "allowOthersToUpdate": true,
    "allowOthersToDelete": false,
    "allowAnonymousToUpdate": true,
    "allowAnonymousToDelete": true
  },
  "layerInfo": {
    "currentVersion": 10.51,
    "id": 0,
    "name": "",
    "type": "Table",
    "displayField": "",
    "description": "",
    "copyrightText": "",
    "defaultVisibility": true,
    "relationships": [],
    "isDataVersioned": false,
    "supportsAppend": true,
    "supportsCalculate": true,
    "supportsTruncate": false,
    "supportsAttachmentsByUploadId": true,
    "supportsAttachmentsResizing": true,
    "supportsRollbackOnFailureParameter": true,
    "supportsStatistics": true,
    "supportsAdvancedQueries": true,
    "supportsValidateSql": true,
    "supportsCoordinatesQuantization": true,
    "supportsApplyEditsWithGlobalIds": false,
    "advancedQueryCapabilities": {
      "supportsPagination": true,
      "supportsPaginationOnAggregatedQueries": true,
      "supportsQueryRelatedPagination": true,
      "supportsQueryWithDistance": true,
      "supportsReturningQueryExtent": true,
      "supportsStatistics": true,
      "supportsOrderBy": true,
      "supportsDistinct": true,
      "supportsQueryWithResultType": true,
      "supportsSqlExpression": true,
      "supportsAdvancedQueryRelated": true,
      "supportsCountDistinct": true,
      "supportsReturningGeometryCentroid": false,
      "supportsQueryWithDatumTransformation": true,
      "supportsHavingClause": true,
      "supportsOutFieldSQLExpression": true
    },
    "useStandardizedQueries": false,
    "geometryType": "esriGeometryPoint",
    "allowGeometryUpdates": true,
    "hasAttachments": false,
    "htmlPopupType": "",
    "hasM": false,
    "hasZ": false,
    "globalIdField": "",
    "typeIdField": "",
    "fields": [
      {
        "name": "x",
        "type": "esriFieldTypeDouble",
        "alias": "x",
        "sqlType": "sqlTypeDouble",
        "nullable": true,
        "editable": true,
        "domain": null,
        "defaultValue": null,
        "locationType": "longitude"
      },
      {
        "name": "city",
        "type": "esriFieldTypeString",
        "alias": "city",
        "sqlType": "sqlTypeNVarchar",
        "length": 256,
        "nullable": true,
        "editable": true,
        "domain": null,
        "defaultValue": null,
        "locationType": "city"
      },
      {
        "name": "y",
        "type": "esriFieldTypeDouble",
        "alias": "y",
        "sqlType": "sqlTypeDouble",
        "nullable": true,
        "editable": true,
        "domain": null,
        "defaultValue": null,
        "locationType": "latitude"
      },
      {
        "name": "matchaddr",
        "type": "esriFieldTypeString",
        "alias": "matchaddr",
        "sqlType": "sqlTypeNVarchar",
        "length": 256,
        "nullable": true,
        "editable": true,
        "domain": null,
        "defaultValue": null,
        "locationType": "unknown"
      },
      {
        "name": "street",
        "type": "esriFieldTypeString",
        "alias": "street",
        "sqlType": "sqlTypeNVarchar",
        "length": 256,
        "nullable": true,
        "editable": true,
        "domain": null,
        "defaultValue": null,
        "locationType": "address"
      },
      {
        "name": "score",
        "type": "esriFieldTypeInteger",
        "alias": "score",
        "sqlType": "sqlTypeInteger",
        "nullable": true,
        "editable": true,
        "domain": null,
        "defaultValue": null,
        "locationType": "unknown"
      },
      {
        "name": "locname",
        "type": "esriFieldTypeString",
        "alias": "locname",
        "sqlType": "sqlTypeNVarchar",
        "length": 256,
        "nullable": true,
        "editable": true,
        "domain": null,
        "defaultValue": null,
        "locationType": "unknown"
      },
      {
        "name": "st",
        "type": "esriFieldTypeString",
        "alias": "st",
        "sqlType": "sqlTypeNVarchar",
        "length": 256,
        "nullable": true,
        "editable": true,
        "domain": null,
        "defaultValue": null,
        "locationType": "state"
      },
      {
        "name": "no",
        "type": "esriFieldTypeInteger",
        "alias": "no",
        "sqlType": "sqlTypeInteger",
        "nullable": true,
        "editable": true,
        "domain": null,
        "defaultValue": null,
        "locationType": "unknown"
      }
    ],
    "indexes": [],
    "types": [],
    "templates": [
      {
        "name": "New Feature",
        "description": "",
        "drawingTool": "esriFeatureEditToolPoint",
        "prototype": {
          "attributes": {
            "x": null,
            "city": null,
            "y": null,
            "matchaddr": null,
            "street": null,
            "score": null,
            "locname": null,
            "st": null,
            "no": null
          }
        }
      }
    ],
    "supportedQueryFormats": "JSON, geoJSON",
    "hasStaticData": false,
    "maxRecordCount": -1,
    "standardMaxRecordCount": 32000,
    "tileMaxRecordCount": 8000,
    "maxRecordCountFactor": 1,
    "capabilities": "Create,Delete,Query,Update,Editing"
  }
}
upsert

(Optional)

Used to specify whether the edits needs to be applied as updates if the feature already exists. The default value is false.

Values: true | false

skipInserts

(Optional)

Used only when upsert is true. Used to skip inserts if the value is true. The default value is false.

Values: true | false

skipUpdates

(Optional)

Used only when upsert is true. Used to skip updates if the value is true. The default value is false.

Values: true | false

useGlobalIds

(Optional)

Used to specify whether upsert needs to use GlobalId when matching features. The default value is false and ObjectId is used by default.

Values: true | false

updateGeometry

(Optional)

Used only when upsert is true. Skip updating the geometry and update only the attributes for existing features if they match source features by objectId or globalId (as specified by the useGlobalIds parameter). The default value is true.

Values: true | false

appendFields

Restricts the list of destination fields that are appended, instead of automatically matching names. This is supported when upsert is specified.

Example

appendFields=["FACILITYID","FLOW","DESC"]
upsertMatchingField

The layer field to be used when matching features with upsert. ObjectId, GlobalId, and any other field that has a unique index can be used with upsert. This parameter overrides useGlobalIds. For example, upsertMatchingField will be used even if you specify useGlobalIds as true.

Example

upsertMatchingField="MyfieldWithUniqueIndex"
appendUploadId

The ID for the uploaded item that contains the source file. Used in conjunction with editUploadFormat. The uploadId can be passed to the append operation if analyzing the data is not needed. Any uploaded items are temporary items and will be cleaned by the system. The uploads operation supports single-item uploads to 10M and multipart uploads for files larger than 10M.

Example

appendUploadId=0c6b928f590f49ebac04761bab413e49
appendItemId

The ID for the geowarehouse item that contains the source file. This parameter is used in conjunction with editsUploadFormat. The source file can be added as an item to your portal, and the itemId can be passed to the append operation. The itemId can be used to analyze the source data file to learn information about the source field's name and to provide a UX to map the source fields to the destination layer fields. The item added using the addItem operation is permanent and would need to be cleaned up, if necessary, by the caller after the append operation is finished.

Example

appendItemId=894d8c12438v4baaac164b636f7e1e2f
appendUploadFormat

The source append data format. The default is the featureCollection format.

Values: sqllite | shapefile | filegdb | featureCollection | geojson | csv | excel

rollbackOnFailure

(Optional)

Used to specify whether the upsert edits need to be rolled back in case of failure. The default value is false.

Value: true | false

f

The response format. The default value is html.

Value: html | json | pjson

Example usage

Append shape file to layer

The following example demonstrates appending data from a shape file (with the uploadID of 0c6b928f590f49ebac04761bab413e49) to the feature service layer:

POST /webadaptor/rest/services/USA/FeatureServer/0/append HTTP/1.1
Host: machine.domain.com
Content-Type: application/x-www-form-urlencoded
Content-Length: []

sourceTableName=&fieldMappings=&edits=&appendSourceInfo=&upsert=false&skipInserts=false&skipUpdates=false&useFlobalIds=false&updateGeometry=false&appendFields=&upsertMatchingFields=&appendUploadId=0c6b928f590f49ebac04761bab413e49&appendItemId=&appendUploadFormat=shapeFile&rollbackOnFailure=&f=pjson

The above request generates the following response:

{
  "status": "processing",
  "statusMessage": "Job Status for jobId: b62e9db7-507c-443d-3473-8a1f7a7e9fac",
  "itemId": "cc7ddbc1e33440688d3110c885fa0b30"
}

The jobId from the response can be used to check the job status by making a request of the following form:

https://machine.domain.com/webadaptor/rest/services/USA/FeatureServer/0/append/jobs/b62e9db7-507c-443d-3473-8a1f7a7e9fac?f=json

If the job is successful, and complete, the above request will return the following response:

{
  "layerName": "CITIES",
  "submissionTime": 1520876908117,
  "lastUpdatedTime": 1520876913647,
  "recordCount": 2,
  "status": "Completed"
}

Append file geodatabase to layer

The following example demonstrates appending data from a file geodatabase (with the uploadID of 0c6b928f590f49ebac04761bab413e49) to the feature service layer:

POST /webadaptor/rest/services/USA/FeatureServer/0/append HTTP/1.1
Host: machine.domain.com
Content-Type: application/x-www-form-urlencoded
Content-Length: []

sourceTableName=Hydrant&fieldMappings=[{"source":"FACILITYID","name":"FACILITYID"},{"source":"FLOW","name":"FLOW"},{"source":"LOCDESC","name":"LOCDESC"}]&edits=&appendSourceInfo=&upsert=false&skipInserts=false&skipUpdates=false&useGlobalIds=false&updateGeometry=true&appendFields=["FACILITYID","FLOW","LOCDESC"]&upsertMatchingField=&appendUploadId=0c6b928f590f49ebac04761bab413e49&appendItemId=&appendUploadFormat=filegdb&rollbackOnFailure=true&f=pjson

The above request generates the following response:

{
  "status": "processing",
  "statusMessage": "Job Status for jobId: feeahh1e-e32c-45bf-680c-f4ed70569081",
  "itemId": "aa7gdww1e55200527d3110c634fa0b30"
}

The jobId from the response can be used to check the job status by making a request of the following form:

https://machine.domain.com/webadaptor/rest/services/USA/FeatureServer/0/append/jobs/feeahh1e-e32c-45bf-680c-f4ed70569081?f=json

If the job is successful, and complete, the above request will return the following response:

{
  "layerName": "Hydrant",
  "submissionTime": 1520876908117,
  "lastUpdatedTime": 1520876913647,
  "recordCount": 5,
  "status": "Completed"
}