How to get binary data of attachment?

PhoenixMing0912
Giga Expert

Hi all,

There is a sample coding which is from service now document.

var attachment_sys_id = 'bacd7034dbeaa3403aff6a4948964f28';
attachmentStream = new GlideSysAttachmentInputStream(attachment_sys_id);

However, attachmentStream is just something like "[B@89e840" but I want the real binary data.

I have read through documents but I didn' t find the answer.

Can anyone help me out?

15 REPLIES 15

matthijsoomen
Giga Guru

Hi PhoenixMing0912,

Did you ever get it to work correctly?
I also need to sent an attachment via a multipart form.

Kind regards,

Matthijs

 

As far as I remember, finally I use Base64 format instead of binary.

You can send binary attachments from ServiceNow to other platforms with multipart, however it is pretty complicated. This article explains it:

https://servicenowthink.wordpress.com/2020/04/13/how-to-send-binary-data-with-multipart-from-servicenow-to-third-party-applications-for-free/

Aleksas Kucins1
Giga Expert

There is no direct way to get binary data in service, you can only get binary representation in a string.