- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-15-2018 10:43 PM
Hi,
I've been having trouble with migrating all of my attachments of a particular table to another instance (From Helsinki to Kingston). I have used the REST attachment API (POST) and created a scheduled job script to run but not all attachments are moved.
REST message:
Script used:
Results are as follow:
I went over to manually attach the particular file and was able to do so. However, I am unable to attach via REST api of another instance.
As I have posted another issue possibly similar to this, I've decided to remove it and edit it onto this post as it may be related.
Any ideas on where did I go wrong or know the solution to the attachment extension issue?
Thanks
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-18-2018 05:42 AM
Joel,
If your target instance returns 404, isn't it simply because the record you are trying to attach the file to doesn't exist on this instance with this table_sys_id ?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-17-2018 11:04 PM
Hi,
Have you tried sending the same attachment via the REST API using a REST client? Postman, RESTED extension, or event the REST API explorer in Servicenow?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-17-2018 11:38 PM
I have used the REST API explorer but was returned with the error 400
The issue for the invalid attachment has been solved. However, another issue arises. Upon executing the script, the logs indicated "No Record found","detail":"Record doesn't exist or ACL restricts the record retrieval".
Using the same script, I have created a scheduled script to run on demand.
Logs:
The user executing the script is an admin and has the roles:
1. web_service_admin
2. rest_service role
The attachment exists in the table as well as the table form.
I have even enabled the option to allow web service to access the table.
Any help will be appreciated!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-17-2018 11:47 PM
Are you able to open the file? Maybe the attachment is here in the sys_attachment table, but not the data in the sys_attachment_doc table.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-17-2018 11:52 PM
Upon clicking the file name, I am able to download the file and opening it seems fine.