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()
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.