Dears,
I want to send Jira requests attachment as base64 format to external system I already have scriptrunner is there any hope to be able to send attachment to External API through listener or automation or any other way
Yes, you can achieve that with a listener.
I hope it helps
// first get the attachment from the event object
def attachment = event.attachment
def attachmentFile = attachment.getFile()
// then base64 decode the file
def bytes = attachmentFile.bytes
def base64 = Base64.encoder.encodeToString(bytes)
// set your body with key, filename and the decoded
def body = [
issueKey : attachment.issue.key,
filename : attachment.filename,
data : base64
]
def response = post("https://your.external.endpoint/")
.header("Content-Type", "application/json")
.body(JsonOutput.toJson(body))
.asString()
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.