Query Attachments (Feature Service/Layer)

Description

The Query Attachments operation is performed on a feature service layer resource. The result of this operation are attachments grouped by the source feature object Ids and global ids (if exist).

You can provide arguments to the Query Attachments operation as query parameters defined in the following parameters table:

NoteNote:

Query attachment is supported if supportedQueryAttachments is true in the feature layer.

Request Parameters

Parameter

Details

f

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

Values: html | json

objectIds

Description: The object IDs of this layer/table to be queried.

Syntax: objectIds=<objectId1>,<objectId2>

Example: objectIds=2. The query results will return attachments only for the specified object id.

globalIds

Description: The global IDs of this layer/table to be queried.

Syntax: globalIds=<globalIds1>,<globalIds2>

Example: globalIds=6s430c5a-kb75-4d52-a0db-b30bg060f0b9,35f0d027-8fc0-4905-a2f6-373c9600d017. The query results will return attachments only for specified global id.

definitionExpression

Description: The definition expression to be applied to the related layer/table. From the list of records that are related to the specified objectIds, only those records that conform to this expression will be returned.

Example: definitionExpression=STATE_NAME = 'Alaska'. The query results will return all attachments in Alaska.

attachmentTypes

Description: The file format that is supported by query attachment.

Supported attachment types:

bmp, ecw, emf, eps, ps, gif, img, jp2, jpc, j2k, jpf, jpg, jpeg, jpe, png, psd, raw, sid, tif, tiff, wmf, wps, avi, mpg, mpe, mpeg, mov, wmv, aif, mid, rmi, mp2, mp3,

mp4, pma, mpv2, qt, ra, ram, wav, wma, doc, docx, dot, xls, xlsx, xlt, pdf, ppt, pptx, txt, zip, 7z, gz, gtar, tar, tgz, vrml, gml, json, xml, mdb, geodatabase

Example: definitionExpression=STATE_NAME = 'Alaska' and attachmentTypes=image/jpeg. The query results will return all image/jpeg attachment type in Alaska

size

Description: The file size of the attachment is specified in bytes. You can enter a file size range (1000,15000) to query for attachments with the specified range.

Example: definitionExpression=STATE_NAME = 'Alaska' and size=1000,15000. The query results will return all attachments within the specified file size range (1000 - 15000) in Alaska

resultOffset

Description: This option fetches query results by skipping a specified number of records. The query results start from the next record (i.e., resultOffset + 1). The default value is 0.

This parameter only applies when supportPagination is true.

You can use this option to fetch records that are beyond maxRecordCount.

Example: If maxRecordCount is 1000, you can get the next 1000 records by setting resultOffset = 1000 and resultRecordCount = 100, so the query results will return the results in the range of 1001 to 1100.

resultRecordCount

Description: This option fetches query results up to the resultRecordCount specified. When resultOffset is specified and this parameter is not, the feature service defaults to the maxRecordCount The maximum value for this parameter is the value of the layer's maxRecordCount property.

This parameter only applies if supportPagination is true.

Example: resultRecordCount=10 to fetch up to 10 records.

Example Usage

JSON response syntax

{
  "fields" : [
    {
      "name" : "OBJECTID", 
      "type" : "<esriFieldTypeInteger>", 
      "alias" : "<OBJECTID>", 
      "sqlType" : "<sqlTypeOther>", 
      "domain" : null, 
      "defaultValue" : null
    }, 
    {
      "name" : "<GlobalID>", 
      "type" : "<esriFieldTypeGlobalID>", 
      "alias" : "<GlobalID>", 
      "sqlType" : "<sqlTypeOther>", 
      "length" : 38, 
      "domain" : null, 
      "defaultValue" : null
    }
  ],
  "attachmentGroups" : [
    
    {
      "parentObjectId" : "<OBJECTID>", 
      "parentGlobalId" : "<esriFieldTypeGlobalID>", 
      
      "attachmentInfos" : [
        {
          "id" : "<OBJECTID>", 
          "globalId" : "<esriFieldTypeGlobalID>", 
          "name" : "<name>", 
          "contentType" : "<attachmentTypes>", 
          "size" : "<size>"
        }
      ]
    }
  ]
}

JSON response example

{
  "fields" : [
    {
      "name" : "OBJECTID", 
      "type" : "esriFieldTypeInteger", 
      "alias" : "<OBJECTID>", 
      "sqlType" : "<sqlTypeOther>", 
      "domain" : null, 
      "defaultValue" : null
    }, 
    {
      "name" : "<GlobalID>", 
      "type" : "<esriFieldTypeGlobalID>", 
      "alias" : "<GlobalID>", 
      "sqlType" : "<sqlTypeOther>", 
      "length" : 38, 
      "domain" : null, 
      "defaultValue" : null
    }
  ], 
  "attachmentGroups" : [
    
    {
      "parentObjectId" : 2, 
      "parentGlobalId" : "60e35c5a-6bc5-4d52-a6db-b39bf566f7b9", 
      
      "attachmentInfos" : [
        {
          "id" : 1, 
          "globalId" : "75dfb06e-8271-4067-aec7-3a56c398b6f3", 
          "name" : "Photo1.jpg", 
          "contentType" : "image/jpeg", 
          "size" : 227367
        }
      ]
    }
  ]
}

7/5/2017