Service now Attachment API NOT able to view the posted attachments

97 Views Asked by At

I am integrating the service now in Fiori using REST API.

we are able to post the attachments successfully but not able to view the attachments in service now tool .

converting the attachments to binary format and sending it to backend.

From postman web client successfully posted the attachments and able to view. From the Fiori not able to view.

attachment API - https://testdev.service-now.com/api/now/attachment/file?table_name=incident&table_sys_id=0bc150b21b017150c201caab234bcb81&file_name=sample.png

Binary conversion Logic

var reader = new FileReader();
        reader.onload = function (readerEvt) {
            var binaryString = readerEvt.target.result;
            var binaryOutput = '';
            // converting to Binary format
            var bytes = new Uint8Array(readerEvt.target.result);
            var length = bytes.byteLength;
            for (var i = 0; i < length; i++) {
                binaryOutput += String.fromCharCode(bytes[i]);
            }
            that.attachments.push({
                name: fileName,
                contenttype: fileDetails.type,
                data: binaryOutput
            });
            that.attachmentnames.push(fileName);
        };
        reader.readAsArrayBuffer(fileDetails);

                      }

Can anyone please help me with the payload of posting attachments in snow and the data conversion of the attachments.

Best Regards, Sravya

0

There are 0 best solutions below