REST API from third party and get attachment

Sathiskumar_D
Giga Sage

Hello Everyone,

 

I got third party applications which have cases. I used REST Message to the script and used in script include to pull the data at a scheduled time (using scheduled job). The issue I have here is attachments. So how attachments from third party get attached to cases(just created from rest api integration) in servicenow? 

1 ACCEPTED SOLUTION

Hitoshi Ozawa
Giga Sage
Giga Sage

Satish,

Attachments are saved in sys_attachment table and have a separate API to retrieve them.

Meta information on attachment is retrieved using the /now/attachment/{sys_id} API. {sys_id} here is the sys_id in the sys_attachment table.

https://developer.servicenow.com/dev.do#!/reference/api/rome/rest/c_AttachmentAPI#attachment-GET

To retrieve the content of an attachment, use the /now/attachment/{sys_id}/file

https://developer.servicenow.com/dev.do#!/reference/api/rome/rest/c_AttachmentAPI#attachment-GET-fil...

Following thread has a sample python script to download attachment.

https://community.servicenow.com/community?id=community_question&sys_id=7ffbd8bb1b1f94d4305fea89bd4b...

Attachment APIs can be tested from REST API Explorer. To download the attachment content, use the "Retrieve attachment content (GET)" method. The generated sample code, also, doesn't contain content-type headers so the retrieved file may not come out correct. Be sure to add the content-type when downloading binary files.

find_real_file.png

 

View solution in original post

2 REPLIES 2

Mike Toms
ServiceNow Employee
ServiceNow Employee

Hi Satish,

Take a look at https://developer.servicenow.com/dev.do#!/reference/api/rome/rest/c_AttachmentAPI, it should solve your attachment problems

Hitoshi Ozawa
Giga Sage
Giga Sage

Satish,

Attachments are saved in sys_attachment table and have a separate API to retrieve them.

Meta information on attachment is retrieved using the /now/attachment/{sys_id} API. {sys_id} here is the sys_id in the sys_attachment table.

https://developer.servicenow.com/dev.do#!/reference/api/rome/rest/c_AttachmentAPI#attachment-GET

To retrieve the content of an attachment, use the /now/attachment/{sys_id}/file

https://developer.servicenow.com/dev.do#!/reference/api/rome/rest/c_AttachmentAPI#attachment-GET-fil...

Following thread has a sample python script to download attachment.

https://community.servicenow.com/community?id=community_question&sys_id=7ffbd8bb1b1f94d4305fea89bd4b...

Attachment APIs can be tested from REST API Explorer. To download the attachment content, use the "Retrieve attachment content (GET)" method. The generated sample code, also, doesn't contain content-type headers so the retrieved file may not come out correct. Be sure to add the content-type when downloading binary files.

find_real_file.png