Truncate (Feature Layer)

Description

The truncate operation supports deleting all features or attachments in a hosted feature service layer. The result of this operation is a response indicating success or failure with error code and description.

Support for the truncate operation only applies if supportsTruncate is true on the layer metadata. The operation is supported on the layer admin API and can be invoked by a user who can administer the service. The truncate operation does not return deleted ID's and will reset the auto-increment column Objectid to 1. As well, the operation does not change the schema of the data (does not add, remove, or alter existing database columns, constraints, or indexes).

Note:

The following must apply for supportsTruncate to be true:

  • The layer cannot be a view.
  • The layer cannot be sync enabled.
  • Multiple service layers cannot reference the same data source - For example, multiple layers with different definition queries are published while referencing the same data source.

Request parameters

ParameterDetails
attachmentOnly

Deletes all the attachments for this layer. None of the layer features will be deleted when attachmentOnly=true.

Value: true | false

async

Supports options for asynchronous processing. The default format is false. It is recommended to set async=true for larger datasets.

Value: true | false

f

The response format. The default response format is html.

Values: html | json | pjson

Example usage

Below is a sample URL used to access the truncate operation:

https://services.myserver.com/OrgID/ArcGIS/admin/services/countries-truncate.FeatureServer/0/truncate

JSON Response syntax

When attachmentOnly=true


{
  "success": <true|false>,
  "error": {
    "code": <code>,
    "message": "<description>",
    "details": [
      "<message>"
    ]
  }
}

JSON response example

When truncate succeeds


{
  "success": true
}

When truncate fails


{
  "error": {
    "code": 400, 
    "message": "", 
    "details": [
      "Unable to truncate layer data."
    ]
  }
}

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.