- URL:
- https://<root>/<serviceName>/FeatureServer/<layerId>/append
- Methods:
POST
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 feature
. 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.
By default, the append
operation supports feature
of type Object
and Global
. The reason is because Object
and Global
are indexed and has unique value. Technically you can Upsert
based on any field, as long as it set as index and must be unique.
For example the JSON format for index should look like the following:
{
"name": "FDO_GlobalID",
"fields": "GlobalID",
"isAscending": true,
"isUnique": true,
"description": ""
},
Unique index on source data feature Id
The destination object
or global
fields do not need to be mapped to source fields of the same data type. The source feature
can map to a different field type, as long as the values can be converted to an acceptable destination value for feature
. For example, the destination global
can be mapped to the Global
, Guid
, string
field types; the object
can be mapped to the short
or long
field types.
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. Organization administrators or the service owner can enable or disable the Append
capability for an existing feature service using the update
operation. For more information on how to configure Append and other capabilities on a feature service layer, see Update Definition.
The Append
capability does not require any editing capabilities to be enabled. Features will be inserted or updated when upsert
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 supports
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.
Append sources
The source of the append operation can be one of three parameters: edits, append
, or append
. edits is a literal feature collection string. append
references the item
of a file or hosted feature currently stored in the portal or geowarehouse. append
references the item
of a file uploaded to the server through the uploads operation. The item
of a file in the portal or geowarehouse is completely independent from the item
of a file stored in the server uploads. Unless a file is needed in the portal or geowarehouse, using the uploads API is the recommended method. For ArcGIS Enterprise, append
is supported with 10.9 and later.
ArcGIS Enterprise 11.3 introduces support for appending directly to a hosted feature service from another hosted feature service within the same Enterprise organization (not from a different Enterprise organization or from a source reference feature service). Both relational and spatiotemporal data stores can be used as the target of this operation, only relational can be used as a source at present.
Supported append formats
A feature service that supports append returns the supported
metadata property. This property lists the supported append
values for this operation.
The append formats are as follows:
sqlite
: sqlite databasegeo
: geopackagePackage shapefile
: shapefilefilegdb
: file geodatabasefeature
: feature collectionCollection geojson
: GeoJSONcsv
: Comma separated valuesexcel
: Microsoft Excel formatfeature
: a hosted feature serviceService
Sync and Change Tracking
The upsert
parameter is not supported if the feature service has sync
or change
capabilities enabled. When sync
or change
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 theupsert
parameter. Theappend
operation might be using a very low level database API that might prevent the use of triggers to track the changes from theupsert
parameter. ArcGIS Online feature servicesync
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 afterupsert
. - Attempting to set the
upsert
parameter totrue
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 feature Id
The source feature
(Object
) is only preserved when upsert
is true
. When upsert
is false
, all new rows created will have their new object
or global
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 last
of the feature service will be updated. The extent
will also be updated for ArcGIS Online feature services.
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 append
parameter (source
).
Geocoding (ArcGIS Online)
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 Creation
and Edit
, 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 allows
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
Time zone information is supported in both ArcGIS Online and in ArcGIS Enterprise starting at ArcGIS Enterprise 11.4. Source data time
can be specified in the append
json object similar to the time
passed in when publishing new feature service.
Example
{"dateFieldsTimeReference": {"timeZone": <"timezone">,"respectsDaylightSaving": 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 update
admin API. Similar to a nonmultipatch feature service, object
, global
, 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.
New at 11.2
A new parameter, truncate
, has been added, which allows existing rows to be removed prior to appending new rows.
New at 11.1
The updates and enhancements below have been added to hosted feature services running on a relational data store in ArcGIS Enterprise:
- The Append capability can now be set for qualifying hosted feature service layers to allow non-service owners and non-organization administrators with access to the feature service to run this operation. In prior releases, the Append capability could not be set for hosted feature services, limiting the scope of those who could use this operation on a given hosted feature service.
- The
esri
field type is now supported.Field Type Blob - A field's default value is now applied when a row is added with no provided value when using either this operation or Apply Edits.
Request parameters
Parameter | Details |
---|---|
| Required only when the source data contains more than one table. Example
|
(Optional) | Maps source data to a destination layer. The The Syntax
Example
|
| A literal feature collection JSON string to be used as the source data. Example
|
| This is only needed when appending data from Excel or CSV. The Example
|
| Filters features from the source file. Source formats that support filtering can be determined by inspecting the layer's Syntax
Example
|
(Optional) | Specifies whether the edits needs to be applied as updates if the feature already exists. The default value is Values: |
(Optional) | Skips inserts if the value is Values: |
(Optional) | Skips updates if the value is Values: |
(Optional) | Specifies whether Values: |
(Optional) | Specifies whether existing rows should be truncated prior to appending new rows. The default value is Values: |
(Optional) | Skips updating the geometry and update only the attributes for existing features if they match source features by Values: |
(Optional) | Restricts the list of destination fields that are appended, instead of automatically matching names. This is supported when Example
|
(Optional) | The layer field to be used when matching features with Example
|
(Optional) | Specifies whether The default value is Values: |
| The Example
|
| The ID for the portal item or geowarehouse item that contains the source file or hosted feature service. This parameter is used in conjunction with This ID may also be used for CSV and Excel files to get information using the analyze operation. Analysis can be done to learn information about a source's fields and provide a UX map to the source fields to the destination layer fields. The item added using the Example
|
| The append source data format. The default is the Values: |
| This is needed if the source is featureService. It is used to map a source layer to a destination layer. Only one source can be mapped to a layer. Syntax
example
|
(Optional) | Specifies whether the Value: |
| The response format. The default value is Value: |
Example usage
Example one: append shape file to layer
The following example demonstrates appending data from a shape file (with the item
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 job
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"
}
Example two: append file geodatabase to layer
The following example demonstrates appending data from a file geodatabase (with the item
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 job
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"
}
Example three: append shapefile, upsert by matching objectId
The following example demonstrates appending data from a shapefile (with the item
of 0c6b928f590f49ebac04761bab413e49
) to the feature service layer. The data and geometries will update where the object
is matched and will insert where the object
is not matched:
POST /webadaptor/rest/services/MyService/FeatureServer/0/append HTTP/1.1
Host: machine.domain.com
Content-Type: application/x-www-form-urlencoded
Content-Length: []
sourceTableName=MyShapes&fieldMappings=[{"source":"myShapeDate","name":"datefield"},{"source":"myData","name":"mydata"},{"source":"myData2","name":"mydata2"},{"source":"FID","name":"objectid"}]&upsert=true&skipInserts=false&updateGeometry=true&appendFields=["datefield","mydata","mydata2","objectid"]&appendUploadId=62b7e088a2ff4b3da1a240d72f9994e3&appendUploadFormat=shapefile&rollbackOnFailure=true&f=json
The above request generates the following response:
{
"status": "processing",
"statusMessage": "Job Status for jobId: feeahh1e-e32c-45bf-680c-f4ed70569081",
"itemId": "aa7gdww1e55200527d3110c634fa0b30"
}
The job
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/MyService/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": "MyService",
"submissionTime": 1520876908117,
"lastUpdatedTime": 1520876913647,
"recordCount": 50786,
"status": "Completed"
}
Example four: append a CSV to a table, upsert by matching global ID, skip inserts
The following example demonstrates appending data from a comma-delimited CSV (with the item
of i3ae29394-68f0-43b7-a30a-53fdfe2b4acd
) to a feature service table. Because the CSV does not have geometry, and the heads of the file match the column names exactly, the append
can be empty. The data will update where the global
is matched, and because skip
is true
, it will not insert where global
is not matched.
POST /webadaptor/rest/services/MyService/FeatureServer/0/append HTTP/1.1
Host: machine.domain.com
Content-Type: application/x-www-form-urlencoded
Content-Length: []
upsert=true&skipInserts=true&updateGeometry=false&appendUploadId=i3ae29394-68f0-43b7-a30a-53fdfe2b4acd&appendUploadFormat=csv&rollbackOnFailure=true&f=json&useGlobalIds=true&appendSourceInfo={}
The above request generates the following response:
{
"status": "processing",
"statusMessage": "Job Status for jobId: feeahh1e-e32c-45bf-680c-f4ed70569081",
"itemId": "i3ae29394-68f0-43b7-a30a-53fdfe2b4acd"
}
The job
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/MyService/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": "MyService",
"submissionTime": 1520876908117,
"lastUpdatedTime": 1520876913647,
"recordCount": 506,
"status": "Completed"
}