Retrieve Attachments - GET API
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-19-2021 10:15 PM
Hello,
I am working on pulling attachments from a third party ServiceNow instance to client's ServiceNow. Third party system does not POST the attachments, but we need to pull the attachments on regular intervals.
I am using GET API to retrieve the attachments from the third party to insert them to 'sys_attachment' table. I have a scheduler which run every 2 hours to invoke GET API call via script include.
I am able to insert the record to 'sys_attachment' table, but as guessed these are meta data and there is no content in the file (size bytes = 0).
Can you please suggest if there are any functions available to retrieve the file content too?
I am using this method and passing table_sys_id to retrieve one attachment at a time. (as there is no better way to query the sys_attachment table using company field, creation time OR to pass multiple 'table_sys_id' in the syparm query)
https://<instance>/api/now/attachment?sysparm_query=table_sys_id=${table_sys_id}%5Esys_created_by!%3DrestUser
I referred these articles and they are not exactly related to my requirement.
https://developer.servicenow.com/blog.do?p=/post/saving-restmessagev2-responses-as-attachments/
https://community.servicenow.com/community?id=community_question&sys_id=bc997b5e1be0d0107a5933f2cd4bcba0&view_source=searchResul
Has anyone come across this kind of requirement and got it working? Can you please share your inputs?
Regards,
Viji
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-21-2021 04:44 PM
Any further inputs on this please?
I tried the script in this link in background script and could get the .png file attached to an incident record.
I tried replacing endpoint with the outbound REST Message endpoint, Or even tried with this url (this is the download_link in the REST response)
https://instance/api/now/attachment/28747ca4dba5f814bc6e0z17f396199a/file
I get the REST response saved as the content of file attachment to Incident. I don't get the actual file.