Replacement of Packages.java.io.ByteArrayOutputStream() for writing byte array over SOAP

Gursimran Sing1
Kilo Contributor

What is the replacement of Packages.java.io.ByteArrayOutputStream() for New York version?

We have custom integration with Third party tool. After the upgrade to NewYork, attachments are not passing over SOAP

It is giving below error::
Error MessageIllegal access to method writeTo(java.io.ByteArrayOutputStream) in class com.glide.ui.SysAttachmentInputStream

var attachmentIS = new GlideSysAttachmentInputStream(attachsys_id);
var bytearrayOS = new Packages.java.io.ByteArrayOutputStream();
attachmentIS.writeTo(bytearrayOS);
var content64 = GlideBase64.encode(bytearrayOS.toByteArray());

Can anyone suggest API/function for the replacement of Packages.java.io.ByteArrayOutputStream().

1 ACCEPTED SOLUTION

florin_danis
Kilo Expert

Hi Gursimrun,

It seems ServiceNow changed the signature for the 'writeTo' method.
Try to use "attachmentIS.writeTo(bytearrayOS, 0, 0);" instead of "attachmentIS.writeTo(bytearrayOS);".

Example in the oob script: /sys_script.do?sys_id=468eebfeff447300c2e8a897d53bf16e

I hope this solved your issue.

View solution in original post

5 REPLIES 5

Thanks Florin, this works for me.