Delete Attachments

URL:
https://<root>/<serviceName>/FeatureServer/<layerId>/<featureId>/deleteAttachments
Methods:
POST
Required Capability:
Update
Version Introduced:
10.0

Description

This operation deletes attachments associated with a feature. Deleting an attachment is a feature update; it requires the Update capability. The deleteAttachments operation is performed on a feature service feature resource.

This operation is available only if the layer has advertised that it has attachments. A layer has attachments if its hasAttachments property is true .

The result of this operation is an array of edit result objects. Each edit result indicates whether the edit was successful or not. If successful, the objectId of the result is the ID of the deleted attachment. If unsuccessful, it also includes an error code and an error description.

You can provide arguments to the deleteAttachments operation as defined in the following parameters table:

Request parameters

ParameterDetails

f

The response format. The default response format is html .

Values: html | json

attachmentIds

Description: The IDs of the attachments to be deleted.

Syntax: attachmentIds=<attachmentId1>, <attachmentId2>

Example: attachmentIds=58, 4

gdbVersion

The geodatabase version to apply the edits. This parameter applies only if the isDataVersioned property of the layer is true .

If the gdbVersion parameter is not specified, edits are made to the published map’s version.

Syntax: gdbVersion=<version>

Example: gdbVersion=SDE.DEFAULT

returnEditMoment

This option was added at 10.5 and works with ArcGIS Server services only.

Description: Optional parameter specifying whether the response will report the time attachments were deleted. If returnEditMoment = true , the server will report the time in the response's editMoment key. The default value is false .

Values:true|false

Example: returnEditMoment=true

rollbackOnFailure

Specifies whether the edits should be applied only if all submitted edits succeed. If false , the server will apply the edits that succeed even if some of the submitted edits fail. If true , the server will apply the edits only if all edits succeed. The default value is true .

Not all data supports setting this parameter. Query the supportsRollbackonFailureParameter property of the layer to determine whether a layer supports setting this parameter. If supportsRollbackOnFailureParameter = false for a layer, then when editing this layer, rollbackOnFailure will always be true , regardless of how the parameter is set. However, if supportsRollbackonFailureParameter = true , the rollbackOnFailure parameter value will be honored on edit operations.

Values: true|false

Example: rollbackOnFailure=true

Example usage

In this sample URL, the deleteAttachments operation is performed on feature ID 818654 belonging to layer 0 of the 311Incidents FeatureService:

https://services.myserver.com/lidGgNLxw9LL0SbI/ArcGIS/rest/services/SanFrancisco/311Incidents/FeatureServer/0/818654/deleteAttachments

The input parameter to this operation (attachmentIds) is a list of IDs of attachments to be deleted:

4,58

JSON response syntax

Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
{
 "deleteAttachmentResults": [
  {
   "objectId": <attachmentId1>,
   "globalId": "<globalId1>",
   "success": <true | false>,
   "error" : { //only if success is false
      "code" : <code1>,
      "description" : "<description1>",
    }
  },
  {
   "objectId": <attachmentId2>,
   "globalId": "<globalId2>",
   "success": <true | false>,
   "error" : {
      "code" : <code2>,
      "description" : "<description2>",
    }
  }
 ]
}

JSON response example

Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
{
 "deleteAttachmentResults": [
  {
   "objectId": 58,
   "globalId": null,
   "success": true
  },
  {
   "objectId": 4,
   "globalId": null,
   "success": false,
   "error": {
    "code": 50,
    "description": "Attachment not found"
   }
  }
 ]
}

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