saveResponseBodyAsAttachment doesn't work
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-19-2022 09:19 AM
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());​
*** 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.
- Labels:
-
Integrations
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-19-2022 02:41 PM
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?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-20-2022 01:26 AM
It is set as true, I can create attachments with other Confluence that doesn't need VPN to connect.