Illegal access to constructor com.glide.ui.SysAttachmentInputStream(object)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-22-2024 02:17 AM - edited 10-22-2024 04:20 AM
Hello,
I'm trying to adjust RESTMessageV2 API which will POST desired attachment from SNOW to JIRA within predefined JSON body structure which should look like this:
"attach_to_jira": {
"attachment_date": "YYYY-MM-DD",
"encoded_string": "???",
"content_type": "*/*",
"file_name": "example.pdf",
"u_number": "NUMB0000001"
}
Implementation should also support files larger then 5MB what means that base64 method is not sufficient.
I've already tried setRequestBodyFromAttachment but unfortunately I'm not able to achieve JSON format of body I mentioned above and I'm neither able to extract this attachment encoded string from this kind of request. (what would as well solve my problem)
Anyway at this moment I'm stuck with combination of GlideSysAttachmentInputStream, writeTo & base64 methods which work as charm in background script:
var gsa = new GlideSysAttachmentInputStream(pdfAttachmentSysid);
var baos = new Packages.java.io.ByteArrayOutputStream();
gsa.writeTo(baos, 0, 0);
baos.close();
var base64 = GlideStringUtil.base64Encode(baos);
but in real world scenario and combination with business rule and script include they just refuse to work throwing error:
java.lang.SecurityException: Illegal access to constructor com.glide.ui.SysAttachmentInputStream(object)
Do you have any idea how can I adjust already mentioned methods to achieve my goal or is there anything else what can I try please?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-22-2024 03:04 AM
There is an alternative API.
You can send a POST request to /rest/api/<version>/issue/<issue_id>/attachments
The body is then a multi-part of the attachment.
This endpoint doesn't require you to construct the above JSON body
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-22-2024 04:18 AM
Thanks,
unfortunately for me, request has to contain mentioned JSON info and as well having it in simpler structure is preferred over multi-part requests.
Are you aware about any examples/documentation how to use/adjust this kind of API please?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-22-2024 04:22 AM
You'd need to work with your Jira admin or ask that on the Jira community.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-02-2024 03:53 PM
Did you manage to find a solution?
I have a similar issue. I'm sending attachments to an API that only accepts multipart form and while my code works when testing the action, it does not work when the action is being used in a flow.
I have exactly the same error: Error: Illegal access to constructor com.glide.ui.SysAttachmentInputStream(object)