Error message "attachment does not exist" issued by the ECC queue.

Shuto Sato
Tera Expert

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.

1 ACCEPTED SOLUTION

Maik Skoddow
Tera Patron
Tera Patron

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

View solution in original post

3 REPLIES 3

Maik Skoddow
Tera Patron
Tera Patron

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

Mike, thanks for the quick response.
I configured the ACL per your suggestion and it worked perfectly.
Appreciate it.

I had faced the same issue. Configured ACL and now everything works fine

Thanks