Update Attachment

Description

This operation updates an attachment associated with a feature (POST only). Updating an attachment is a feature update, it requires the Update capability. The updateAttachment operation is performed on a feature service feature resource.

Since this request uploads a file, it must be a multipart request pursuant to IETF RFC1867.

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

See the Limiting upload file size and file types section of Uploads to learn more about default file size and file type limitations imposed for attachments.

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

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

Request parameters

Parameter

Details

f

Description: The response format. The default response format is html.

Values: html | json

attachmentId

Description: The ID of the attachment to be updated.

Example: attachmentId=58

attachment

Description: The file to be uploaded as the updated feature attachment.

The content type, size, and name of the attachment will be derived from the uploaded file.

gdbVersion

//This option was added at 10.1.

Description: 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 updated. 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

uploadId

//This option was added to the July 2014 of ArcGIS Online and ArcGIS 10.4 Server.

Description: The ID of the attachment that has already been uploaded to the server. This parameter only applies if the supportsAttachmentsByUploadId property of the layer is true.

Example usage

Example 1: Update an attachment using the Update Attachment operation on a feature service feature resource. In this sample URL, the Update Attachment operation is performed on feature ID 818654 belonging to layer 0 of the 311Incidents FeatureService:

http://services.myserver.com/lidGgNLxw9LL0SbI/ArcGIS/rest/services/SanFrancisco/311Incidents/FeatureServer/0/818654/updateAttachment

The input parameters to this operation (attachmentId and attachment) are the ID of the attachment to be updated and a file.

JSON response syntax

{
  "updateAttachmentResult": {
    "objectId" : <attachmentId>,
    "globalId" : <globalId>,
    "success" : <true | false>,
    "error" : { //only if success is false
      "code" : <code1>,
      "description" : "<description>",
    }
  }
}

JSON response example

{
  "updateAttachmentResult": {
    "objectId" : 58,
    "globalId" : null,
    "success" : true
  }
}

10/6/2017