How to add a sys_attachment from another ServiceNow instance programmatically
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-14-2023 11:38 PM
Hi All,
I have a use case, where I need to insert a .PEM file as a sys_attachment in a ServiceNow instance from another ServiceNow instance programmatically. I also, need to send the "table_sys_id" field of the sys_attachment to be inserted programmatically. Can SMEs please provide ways to achieve this?
Please let me know if any additional info is required.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-15-2023 08:22 AM
Hello @Dattatreya Trip ,
To insert a .PEM file as a sys_attachment in a ServiceNow instance from another ServiceNow instance programmatically, you can use ServiceNow's REST API. Here are the steps you can follow:
- First, you need to authenticate with the instance you want to insert the attachment into. You can do this by sending a POST request to the instance's endpoint with the appropriate credentials.
- Once you have authenticated, you can use the '/api/now/attachment/file' endpoint to upload the attachment. You will need to include the following information in your request:
- The file contents in the request body
- The file name in the 'file_name' parameter
- The table_sys_id field in the 'table_sys_id' parameter
- The table name in the 'table_name' parameter
- Finally, you can check if the attachment was successfully uploaded by sending a GET request to the '/api/now/attachment' endpoint with the appropriate parameters.
I hope this helps! Let me know if you have any further questions.
Thanks,
Ratnakar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-17-2023 10:11 PM
Thanks for the response. Will give it a try.