Attachment is not opening
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-19-2024 03:53 AM
Hi Team,
I am trying to attach some API response as an excel file to some record in ServiceNow. The file is getting attached to the record, but when I am trying to open it, it is showing one error message as below:-
Please check the below mentioned code I have written and help me to resolve this issue.
var fileResponse = this.utils.makeApiCall("GET", "/reporting/exports/" + exports_id + "/download", "", this.getAuthenticationObject());
if (fileResponse && (fileResponse.getStatusCode() == "200" || fileResponse.getStatusCode() == "201")) {
var fileContent = fileResponse.getBody(); // Get the response body directly
var attachment = new GlideSysAttachment();
// var agr = attachment.write(pdf,fileName, 'text/csv', fileContent);
//var agr = attachment.write(pdf, fileName, 'application/vnd.ms-excel', fileContent);
var agr = attachment.write(pdf, fileName, 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', fileContent);
}
Thanks in advance!
Please help me to resolve this issue ASAP, its urgent.
1 REPLY 1
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-19-2024 07:11 AM
are you getting the base64 encoded data from the API response?
are you in global scope or scoped app?
Regards,
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader