Community Announcements have moved! To stay up to date, please join the new Community Announcements group today. Learn more
×Could you please give me a help?
I'm writing the script which copy an attachment from space to space. But I can't get a path for attachment.
def filePath = null
RequestFilePart requestFilePart = new RequestFilePart("application/octet-stream", attach.first().title.toString(), filePath, "file")
List<RequestFilePart> fileParts = new ArrayList<RequestFilePart>()
fileParts.add(requestFilePart)
authenticatedRequestFactory
.createRequest(Request.MethodType.POST, "rest/api/content/" + conf.id + "/child/attachment")
.addHeader("X-Atlassian-Token", "nocheck")
.setFiles(fileParts)
.execute(new ResponseHandler<Response>() {
@Override
void handle(Response response) throws ResponseException {
if(response.statusCode != HttpURLConnection.HTTP_OK) {
throw new Exception(response.getResponseBodyAsString())
} else {
def webUrl = new JsonSlurper().parseText(response.responseBodyAsString)["_links"]["webui"]
}
}
})
Hi! You have an "attach" variable but no declaration of it.
If in the second line your code declaration "attach" variable look like this:
def attach = page.getAttachments()
You can get the attachment path as follows:
attach.first().getDownloadPath().toString()
Unlock your potential and learn how to use Jira Product Discovery to your advantage. You’ll have the expertise to revolutionize ideas and insights, roadmapping, engage and align teams and stakeholders, and deliver the best solutions—faster. Enroll today!
Start Learning
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.