saveResponseBodyAsAttachment doesn't work

REN11
Kilo Explorer

Hi,

I want to copy attachments of the Confluence to the record of the ServiceNow, it needs VPN to access the Confluence. I used REST message to call and MID server to access the Confluence. Although it works in the test of the REST message, which returns text in the response field, it doesn't work with the method saveResponseBodyAsAttachment, here is my script:

 
var r =new sn_ws.RESTMessageV2('xxxxx','xxxx');
r.setStringParameter('xxxx', "xxxxxx");
r.setStringParameter('xxxxx', "xxxxx");
r.saveResponseBodyAsAttachment("xxxxxx", "xxxxxx", "xxxxx");
var response = r.execute();
var httpStatus = response.getStatusCode();
gs.print(httpStatus);
gs.print(response.haveError());
gs.print(response.getResponseAttachmentSysid());
gs.print(response.getHeader('Content-Type'));
gs.print(response.getErrorMessage());​
 
And when I run the script, it returns:
*** Script: 200
*** Script: true
*** Script: null
*** Script: application/pdf;charset=UTF-8
*** Script: Unable to save response body as attachment: User not authorized

And it doesn't create the attachment neither in the record and in the sys_attachment.

Thanks in advance.

2 REPLIES 2

Tony Chatfield1
Kilo Patron

Hi, unfortunately there is little in your code that can be assessed as you have XXX out all details.
But based on the error message it seems probable that the user account involved does not have rights to create to sys_attachment table via integration.
Is 'Allow access to this table via web services' flagged true for sys_attachment?

It is set as true, I can create attachments with other Confluence that doesn't need VPN to connect.