Hi guys,
I am trying to synchronize attachments between two instances. I have this code:
def attachment = get("https://jira.atlassian.net/rest/api/3/attachment/content/{attachmentId}") // get the content binary data
.basicAuth("e-mail@address.com", "token")
.asBinary()
.body
def attachmentData = get("https://jira.atlassian.net/rest/api/3/attachment/{attachmentId}") // get the attachment metadata
.basicAuth("e-mail@address.com", "token")
.asObject(Map)
.body
def fileName = attachmentData['filename'] as String
InputStream stream = new ByteArrayInputStream(attachment.getBytes()) // create a file to send
def sendAttachment = post("/rest/api/3/issue/{issueID}/attachments")
.header("Accept", "application/json")
.header("X-Atlassian-Token", "no-check")
.field("file", stream, fileName)
.asJson()
I can upload the attachment into an issue, but if it's name contains special character like "Český jazyk.txt" it will replace the characters by "?", so the name of created attachment will be "?esk? jazyk.txt". And this is the problem I need to resolve.
Many thanks for any suggestions.
Lukas