Reference

Endpoint Get Attachments


Name

get_attachments

Description

Get attachment details for a specified table or table + parent sys_id (e.g. incident) or a specific attachment sys_id. You can also search using search criterial related to attachment record (e.g. filename starts with xyz) [API reference]

Parameters

Parameter Required Options
Name: PagingRowCount

Label: Page Size (Default=2000, Max=10000)

Max can be 10000 but it may decrease performance if you fetching less than 10K rows in some requests.
YES
Name: TableName

Label: TableName (for attachments)

Table name for which you like to list attachment. If you supply sys_id of attachment then no need to supply this
Name: ParentSysId

Label: ParentSysId

Parent Table Row 'sys_id' for which you like to get attachments
Name: Fields

Label: Fields to include in response (Keep blank to get all fields -OR- Enter comma separated list)

Comma-separated field names you want to return in the response. E.g. sys_id,name,label,sys_name,sys_updated_on. Using this setting reduces the response size and speed up the processing.
Name: Query

Label: Attachment Filter / Order By

Server-side filter for sys_attachment (file name, size, type, date, parent record, etc.)
Option Value
Uploaded Today sys_created_on>=<>^sys_created_on<=<>
Uploaded Last 2 Days sys_created_on>=<>
Uploaded After Date sys_created_on>=2026-01-01
File Name Equals file_name=dump.png
File Name Starts With file_nameSTARTSWITHdump
File Name Contains file_nameLIKEerror
File Name Ends With file_nameENDSWITH.pdf
Images Only content_typeSTARTSWITHimage/
Larger Than 1MB size_bytes>1048576
Uploaded By User sys_created_by=admin
Order By Created Date ORDERBYsys_created_on
Order By Size Desc ORDERBYDESCsize_bytes
Name: PagingOffset

Label: PagingOffset

Name: SysId

Label: SysId

Row 'sys_id'

Output Columns

Label Data Type (SSIS) Data Type (SQL) Length Description
sys_id DT_WSTR nvarchar(32) 32
table_sys_id DT_WSTR nvarchar(32) 32
file_name DT_WSTR nvarchar(512) 512
content_type DT_WSTR nvarchar(255) 255
hash DT_WSTR nvarchar(64) 64
state DT_WSTR nvarchar(50) 50
size_bytes DT_I8 bigint
size_compressed DT_I8 bigint
chunk_size_bytes DT_I8 bigint
image_width DT_I4 int
image_height DT_I4 int
average_image_color DT_WSTR nvarchar(16) 16
compressed DT_BOOL bit
table_name DT_WSTR nvarchar(80) 80
sys_created_by DT_WSTR nvarchar(128) 128
sys_updated_by DT_WSTR nvarchar(128) 128
sys_tags DT_WSTR nvarchar(1024) 1024
sys_created_on DT_DBTIMESTAMP datetime
sys_updated_on DT_DBTIMESTAMP datetime
sys_mod_count DT_I4 int
If the column you are looking for is missing, consider customizing ServiceNow Connector.

Input Columns

Label Data Type (SSIS) Data Type (SQL) Length Description
There are no Static columns defined for this endpoint. This endpoint detects columns dynamically at runtime.

Examples

SSIS

Use ServiceNow Connector in API Source or in API Destination SSIS Data Flow components to read or write data.

API Source

API Source - ServiceNow
Read and write ServiceNow data effortlessly. Integrate, manage, and automate incidents, tasks, attachments, and records — almost no coding required.
ServiceNow
Get Attachments
Optional Parameters
TableName (for attachments)
ParentSysId
Fields to include in response (Keep blank to get all fields -OR- Enter comma separated list)
Attachment Filter / Order By
SSIS API Source - Read from table or endpoint

API Destination

API Destination - ServiceNow
Read and write ServiceNow data effortlessly. Integrate, manage, and automate incidents, tasks, attachments, and records — almost no coding required.
ServiceNow
Get Attachments
Optional Parameters
TableName (for attachments)
ParentSysId
Fields to include in response (Keep blank to get all fields -OR- Enter comma separated list)
Attachment Filter / Order By
SSIS API Destination - Access table or endpoint

ODBC application

Use these SQL queries in your ODBC application data source:

Get Attachments Information (With Optional Attachment Filter)

-- Get all attachments for the parent table 'problem'
SELECT * FROM get_attachments WITH(TableName='problem')

-- Get attachments where file name ends with .png or .zip (attachment table filter)
SELECT * FROM get_attachments WITH(TableName='problem', Query='file_nameENDSWITH.png^ORfile_nameENDSWITH.zip')

-- Get all attachments for a specific parent record (by parent sys_id)
SELECT * FROM get_attachments WITH(TableName='problem', ParentSysId='62304320731823002728660c4cf6a7e8')

-- Get a single attachment metadata row by exact attachment sys_id
SELECT * FROM get_attachments WITH(SysId='4b2d41168396b21032ddb9f6feaad38f')

-- Get attachments uploaded today
SELECT * FROM get_attachments WITH(TableName='problem', Query='sys_created_on>=<<today,FUN_TO_DATETIME>>^sys_created_on<=<<today|~|yyyy-MM-dd 23:59:59,FUN_TO_DATETIME>>')

-- Get attachments uploaded in the last 2 days
SELECT * FROM get_attachments WITH(TableName='problem', Query='sys_created_on>=<<today-2d,FUN_TO_DATETIME>>')

-- Get attachments uploaded after a specific date
SELECT * FROM get_attachments WITH(TableName='problem', Query='sys_created_on>=2026-01-01')

-- Get attachments with exact file name match
SELECT * FROM get_attachments WITH(TableName='problem', Query='file_name=dump.png')

-- Get attachments where file name starts with 'dump'
SELECT * FROM get_attachments WITH(TableName='problem', Query='file_nameSTARTSWITHdump')

-- Get attachments where file name contains 'error'
SELECT * FROM get_attachments WITH(TableName='problem', Query='file_nameLIKEerror')

-- Get attachments where file name ends with .pdf
SELECT * FROM get_attachments WITH(TableName='problem', Query='file_nameENDSWITH.pdf')

-- Get only image attachments
SELECT * FROM get_attachments WITH(TableName='problem', Query='content_typeSTARTSWITHimage/')

-- Get attachments larger than 1 MB
SELECT * FROM get_attachments WITH(TableName='problem', Query='size_bytes>1048576')

-- Get attachments uploaded by a specific user
SELECT * FROM get_attachments WITH(TableName='problem', Query='sys_created_by=admin')

-- Order attachments by created date (ascending)
SELECT * FROM get_attachments WITH(TableName='problem', Query='ORDERBYsys_created_on')

-- Order attachments by size descending
SELECT * FROM get_attachments WITH(TableName='problem', Query='ORDERBYDESCsize_bytes')

SQL Server

Use these SQL queries in SQL Server after you create a data source in Data Gateway:

Get Attachments Information (With Optional Attachment Filter)

DECLARE @MyQuery NVARCHAR(MAX) = '-- Get all attachments for the parent table ''problem''
SELECT * FROM get_attachments WITH(TableName=''problem'')

-- Get attachments where file name ends with .png or .zip (attachment table filter)
SELECT * FROM get_attachments WITH(TableName=''problem'', Query=''file_nameENDSWITH.png^ORfile_nameENDSWITH.zip'')

-- Get all attachments for a specific parent record (by parent sys_id)
SELECT * FROM get_attachments WITH(TableName=''problem'', ParentSysId=''62304320731823002728660c4cf6a7e8'')

-- Get a single attachment metadata row by exact attachment sys_id
SELECT * FROM get_attachments WITH(SysId=''4b2d41168396b21032ddb9f6feaad38f'')

-- Get attachments uploaded today
SELECT * FROM get_attachments WITH(TableName=''problem'', Query=''sys_created_on>=<<today,FUN_TO_DATETIME>>^sys_created_on<=<<today|~|yyyy-MM-dd 23:59:59,FUN_TO_DATETIME>>'')

-- Get attachments uploaded in the last 2 days
SELECT * FROM get_attachments WITH(TableName=''problem'', Query=''sys_created_on>=<<today-2d,FUN_TO_DATETIME>>'')

-- Get attachments uploaded after a specific date
SELECT * FROM get_attachments WITH(TableName=''problem'', Query=''sys_created_on>=2026-01-01'')

-- Get attachments with exact file name match
SELECT * FROM get_attachments WITH(TableName=''problem'', Query=''file_name=dump.png'')

-- Get attachments where file name starts with ''dump''
SELECT * FROM get_attachments WITH(TableName=''problem'', Query=''file_nameSTARTSWITHdump'')

-- Get attachments where file name contains ''error''
SELECT * FROM get_attachments WITH(TableName=''problem'', Query=''file_nameLIKEerror'')

-- Get attachments where file name ends with .pdf
SELECT * FROM get_attachments WITH(TableName=''problem'', Query=''file_nameENDSWITH.pdf'')

-- Get only image attachments
SELECT * FROM get_attachments WITH(TableName=''problem'', Query=''content_typeSTARTSWITHimage/'')

-- Get attachments larger than 1 MB
SELECT * FROM get_attachments WITH(TableName=''problem'', Query=''size_bytes>1048576'')

-- Get attachments uploaded by a specific user
SELECT * FROM get_attachments WITH(TableName=''problem'', Query=''sys_created_by=admin'')

-- Order attachments by created date (ascending)
SELECT * FROM get_attachments WITH(TableName=''problem'', Query=''ORDERBYsys_created_on'')

-- Order attachments by size descending
SELECT * FROM get_attachments WITH(TableName=''problem'', Query=''ORDERBYDESCsize_bytes'')';

EXEC (@MyQuery) AT [LS_TO_SERVICENOW_IN_GATEWAY];