- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-26-2024 12:49 AM
Hello.
I am currently investigating how to use REST Message to link data from ServiceNow to other systems.
In particular, we need to send a file attached to a record and would like to use sn_ws.RESTMessageV2().setRequestBodyFromAttachment().
So I wrote and tested the script shown below and it returned 0 as HTTP status.
try {
var request = new sn_ws.RESTMessageV2();
request.setMIDServer('[Mid Server name]');
request.setHttpMethod('POST');
request.setEndpoint('[endpoint]');
request.setRequestBodyFromAttachment('[sys_id]');
var response = request.execute();
var responseBody = response.getBody();
var httpStatus = response.getStatusCode();
gs.info(httpStatus);
}
catch (ex) {
var message = ex.message;
}
When I checked the ECC queue, I got the following error message.
<?xml version="1.0" encoding="UTF-8"? >
<results error="attachment does not exist with sys_id: ([sys_id])" probe_time="62" result_code="900000">
<parameters>...
I checked to see if the sys_id I described in the script was correct, but sure enough, the record with the sys_id in question exists on the sys_attachment table.
Am I misunderstanding something?
Any advice would be appreciated.
Thank you.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-26-2024 05:49 AM
Hi @Shuto Sato
the reason is probably the mid server user has not enough rights to read the attachment. So add the "mid_server" role to a "read" ACL of the sys_attachment table and it should work.
Maik
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-26-2024 05:49 AM
Hi @Shuto Sato
the reason is probably the mid server user has not enough rights to read the attachment. So add the "mid_server" role to a "read" ACL of the sys_attachment table and it should work.
Maik
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-28-2024 04:50 PM
Mike, thanks for the quick response.
I configured the ACL per your suggestion and it worked perfectly.
Appreciate it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-11-2024 05:07 AM
I had faced the same issue. Configured ACL and now everything works fine
Thanks