- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-24-2020 09:31 AM
Hello Friends,
I am using the REST API call and saving the response body using the method - "saveResponseBodyAsAttachment(tablename, recordSysId, filename); ". I am setting the MID server to execute the request. Above method execution is failing with "Unable to save response body as attachment: User not authorized " error.
Please guide.
Thanks,
Rahul
Solved! Go to Solution.
- Labels:
-
MID Server
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-22-2020 08:25 AM
This is what we are doing:
1. Getting the ResponseBody.
var response = sm.execute();
var responseBody = response.getBody();
2. Creating an attachment using the below code, where gr is the GlideRecord to which file is attached.
attachment.write(gr,"SampleJson","json",responseBody);
It worked for me.
Thanks,
Rahul
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-25-2020 06:31 AM
Hi Rahul,
Is that user having valid role to add attachment to data source?
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-25-2020 09:14 AM
Do i need to check access to attachment table ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-25-2020 09:41 AM
Hi Rahul,
for adding attachment to data source table user should have import_admin role and user with that role can run transform map
Mark ✅ Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-22-2020 08:14 AM
Hi, I have exactly the same problem and I’m admin. How can I fix this?
In our case, the API returns an application/pdf in the attachment of the http response.
I'm on New York.
thanks
Marc
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-22-2020 08:25 AM
This is what we are doing:
1. Getting the ResponseBody.
var response = sm.execute();
var responseBody = response.getBody();
2. Creating an attachment using the below code, where gr is the GlideRecord to which file is attached.
attachment.write(gr,"SampleJson","json",responseBody);
It worked for me.
Thanks,
Rahul