- URL:
- https://<mapLayer-url>/queryAttachments
- Methods:
GET
Description
The Query Attachments operation is performed on a map service layer resource. The result of this operation are attachments grouped by the source feature object Ids and global ids (if exist).
Queries must include one of the following parameters: object
, global
, or definition
. All other parameters are optional and are used to further refine the returned results.
You can provide arguments to the Query Attachments operation as query parameters defined in the following parameters table:
New at 10.8.1
- Field names are now returned in addition to the field properties in the
query
operation response. If the field name and property name match, including case, only one value is returned in the response to represent both field and property. As a best practice, it is best to go by the fieldname rather than the property when consuming this in an application.Attachments - When using the
attachments
parameter, you can use theDefinition Expression field
property from the layer'sName attachment
object. This describes the names of the fields that can be used in the expression. The layer'sProperties attachment
object lists more information about these fields, including type, which can be useful when building queries. This information is not provided in the layer resource at earlier releases, but the same field names can be used in those as well.Fields
Request parameters
Parameter | Details |
---|---|
(Required) | The object IDs of this layer/table to be queried. This parameter is not designed to be used in conjunction with the Syntax
Example
|
(Required) | The global IDs of this layer/table to be queried. This parameter is required if neither Syntax
Syntax: Example
|
(Required) | The definition expression to be applied to the layer. Only those records that conform to this expression will be returned. This parameter is required if neither Example
|
| The definition expression to be applied to the attachments table. Only those records that conform to this expression will be returned. You can get the attachments table field names to use in the expression by checking the layer's Examples
|
| The attachment types to return. The following attachment types are supported for ArcGIS Online and ArcGIS Enterprise: Values: At this time, the following attachment types are supported in ArcGIS Online only: Values: Example
|
| 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
|
| This parameter is designed to be used in conjunction with Example resultOffset setting
|
| This option fetches query results up to the Example
|
| Specifies whether to return the attachment URL. The default is Values: |
| If Values: |
| Returns attachments that match the keywords provided. The value provided for this parameter must be an exact match to the attachment's keyword value. This parameter can be set when the layer's Example
|
| The response format. The default response format is Values: |
Example usage
Example one
The example below demonstrates how to query attachments using the parent objects
. The query results will return only the specified object ids.
https://machine.domain.com/webadaptor/rest/services/light-inventory/MapServer/0/queryAttachments?objectIds=2,4&globalIds=&definitionExpression=&attachmentTypes=&resultOffset=&resultRecordCount=&f=pjson
Example two
The example below demonstrates how to query attachments using the parent global
. The query results will returns only the specified global ids.
https://machine.domain.com/webadaptor/rest/services/light-inventory/MapServer/0/queryAttachments?objectIds=&globalIds=60e35c5a-6bc5-4d52-a6db-b39bf566f7b9,e1f9d927-8fc9-4995-a2f6-373c9600d017&definitionExpression=&attachmentTypes=&size=&resultOffset=&resultRecordCount=&f=pjson
Example three
The example below demonstrates how to query attachments using the definition
as objectid>
and attachment
as impage
/jpeg. The query results will return all image/jpeg attachment types where the object id is greater than 2.
https://machine.domain.com/webadaptor/rest/services/light-inventory/MapServer/0/queryAttachments?objectIds=&globalIds=&definitionExpression=objectid>2&attachmentTypes=image/jpeg&size=&resultOffset=&resultRecordCount=&f=html
Example four
The example below demonstrates how to query attachments using the definition
STATE_
as 'alaska'
, result
as 5, and result
as 10. The query results will skip the first 5 records and return the next 10 attachments in Alaska.
https://machine.domain.com/webadaptor/rest/services/light-inventory/MapServer/0/queryAttachments?objectIds=2&globalIds=&definitionExpression=STATE_NAME = 'alaska'&attachmentTypes=&size=&resultOffset=5&resultRecordCount=10&f=html
Example five
The example below demonstrates how to query attachments using the attachments
ATT_
as 'alaska_
and size
as 900,7000
. The query results will return all attachments within the specified file size range with the attachment name 'alaska.geodatabase'
.
https://machine.domain.com/webadaptor/rest/services/light-inventory/MapServer/0/queryAttachments?objectIds=2&globalIds=&definitionExpression=ATT_NAME = 'alaska.geodatabase'&attachmentTypes=&size=900,7000&resultOffset=&resultRecordCount=&f=html
Example six
The example below demonstrates how to query attachments using the definition
STATE_
as 'alaska'
, size
as 900,7000
, and return
as true
. The query results will return all attachments, including URLs, within the specified file size range in Alaska.
https://machine.domain.com/webadaptor/rest/services/light-inventory/MapServer/0/queryAttachments?objectIds=2&globalIds=&definitionExpression=STATE_NAME = 'alaska'&attachmentTypes=&size=900,7000&resultOffset=&resultRecordCount=&returnUrl=true&f=html
Example seven
The example below demonstrates how to query attachments using the definitionExpression as 1=1 and keywords as 'motorcycle'. The query results will return all attachment types that have a keywords value of motorcycle.
https://machine.domain.com/webadaptor/rest/services/Hosted/volcano_roop/MapServer/0/queryAttachments?definitionExpression=1%3D1&keywords=motorcycle&f=json
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>",
"url": "<returnUrl>"
}
]
}
]
}
JSON Response example
{
"fields": [
{
"name": "objectid_1",
"type": "esriFieldTypeOID",
"alias": "OBJECTID_1",
"domain": null,
"defaultValue": null
},
{
"name": "globalid",
"type": "esriFieldTypeGlobalID",
"alias": "globalid",
"domain": null,
"defaultValue": null
}
],
"attachmentGroups": [
{
"parentObjectId": 2,
"parentGlobalId": "{F62F4A99-FACB-459D-8E29-7A1044EE2065}",
"attachmentInfos": [
{
"id": 1204,
"attachmentid": 1204,
"globalId": "{058333D1-D96C-4C19-A787-553FF119FD53}",
"globalid": "{058333D1-D96C-4C19-A787-553FF119FD53}",
"name": "red.png",
"att_name": "red.png",
"contentType": "image/png",
"content_type": "image/png",
"size": 381,
"data_size": 381
}
]
}
]
}