Attachment API - GET /now/attachment/{sys_id}

This method gets the metadata for the attachment file with a specific sys_id value.

URL format

Versioned URL: api/now/v1/attachment/<attachment record sys_id>

Default URL: api/now/attachment/<attachment record sys_id>

Supported request parameters

Table 1. Parameters
Parameter Description
sys_id The sys_id of the attachment record you want to get metadata for.

Headers

The following request and response headers apply to this HTTP action only, or apply to this action in a distinct way. For a list of general headers used in the REST API, see Supported REST API headers.

Table 2. Request headers
Header Description
None
Table 3. Response headers
Header Description
Content-Type The content type of the response. For metadata requests, this is the content type of the metadata, not the content type of the attachment files.

Status codes

The following status codes apply to this HTTP action. For a list of possible status codes used in the REST API, see REST response codes .

Table 4. Status codes
Status code Description
200 Indicates the query ran successfully.
404 Indicates the specified attachment does not exist, or the current user cannot access it.

Sample cURL request

curl "https://instance.service-now.com/api/now/attachment/615ea769c0a80166001cf5f2367302f5" \
--request GET \
--header "Accept:application/json" \
--user 'admin':'admin'
{
  "result": {
    "table_sys_id": "5054b6f8c0a800060056addcf551ecf8",
    "size_bytes": "462",
    "download_link": "https://instance.service-now.com/api/now/attachment/615ea769c0a80166001cf5f2367302f5/file",
    "sys_updated_on": "2009-05-21 04:12:21",
    "sys_id": "615ea769c0a80166001cf5f2367302f5",
    "image_height": "",
    "sys_created_on": "2009-05-21 04:12:21",
    "file_name": "blocks.swf",
    "sys_created_by": "glide.maint",
    "compressed": "true",
    "average_image_color": "",
    "sys_updated_by": "glide.maint",
    "sys_tags": "",
    "table_name": "content_block_programmatic",
    "image_width": "",
    "sys_mod_count": "0",
    "content_type": "application/x-shockwave-flash",
    "size_compressed": "485"
  }
}

Sample Python request

#Need to install requests package for python
#easy_install requests
import requests

# Set the request parameters
url = 'https://instance.service-now.com/api/now/attachment/615ea769c0a80166001cf5f2367302f5'

# Eg. User name="admin", Password="admin" for this code sample.
user = 'admin'
pwd = 'admin'

# Set proper headers
headers = {"Content-Type":"application/xml","Accept":"application/xml"}

# Do the HTTP request
response = requests.get(url, auth=(user, pwd), headers=headers  )

# Check for HTTP codes other than 200
if response.status_code != 200: 
    print('Status:', response.status_code, 'Headers:', response.headers, 'Error Response:',response.json())
    exit()

# Decode the JSON response into a dictionary and use the data
data = response.json()
print(data)
<?xml version="1.0" encoding="UTF-8"?>
<response>
   <result>
      <table_sys_id>5054b6f8c0a800060056addcf551ecf8</table_sys_id>
      <size_bytes>462</size_bytes>
      <download_link>https://instance.service-now.com/api/now/attachment/615ea769c0a80166001cf5f2367302f5/file</download_link>
      <sys_updated_on>2009-05-21 04:12:21</sys_updated_on>
      <sys_id>615ea769c0a80166001cf5f2367302f5</sys_id>
      <image_height />
      <sys_created_on>2009-05-21 04:12:21</sys_created_on>
      <file_name>blocks.swf</file_name>
      <sys_created_by>glide.maint</sys_created_by>
      <compressed>true</compressed>
      <average_image_color />
      <sys_updated_by>glide.maint</sys_updated_by>
      <sys_tags />
      <image_width />
      <table_name>content_block_programmatic</table_name>
      <sys_mod_count>0</sys_mod_count>
      <content_type>application/x-shockwave-flash</content_type>
      <size_compressed>485</size_compressed>
   </result>
</response>