Hi All,
I have a page with an excel attachment, I want to be able to create new confluence pages from Jira that have a link to that attachment so that all pages are editing the same document.
I get the link to the attachment using the get
{_links={base=http://******:8090, context=, self=http://*******:8090/rest/api/content/5242957/child/attachment?filename=FM00872.xlsx}, limit=50, results=[], size=0, start=0}
// get attachment
def attach = "rest/api/content/"+ page_id + "/child/attachment?filename=FM00872.xlsx"
log.debug attach
authenticatedRequestFactory
.createRequest(Request.MethodType.GET, attach)
.addHeader("Content-Type", "application/json")
.execute(
new ResponseHandler<Response>()
{
@Override
void handle(Response response) throws ResponseException {
confResponse = new JsonSlurper().parseText(response.getResponseBodyAsString())
log.debug confResponse
}
})
but now how do I add it to the new page? I have this code that will load a file as an attachment. But I don't have a file now, just a url link. So what do I use in place of .setFiles()
It doesn't matter to me if it shows up in the second page as a link or an excel attachment as long as the user can open and edit it.
If it is a link in the page rather than an attachment I would like to be able to just click on the link and have it open in excel, is that possible? if so I believe I would need the link to look something more like
<a href="/plugins/servlet/confluence/editinword/5242957/attachments/FM00872.xlsx" rel="nofollow" class="office-editable-pathauth" title="">
<span>
Edit in Office
</span> </a>
// Add attachment as child
authenticatedRequestFactory
.createRequest(Request.MethodType.POST, "rest/api/content/" + page_id + "/child/attachment")
.addHeader("X-Atlassian-Token", "nocheck")
.setFiles(partList)
.execute(new ResponseHandler<Response>() {
@Override
void handle(Response response) throws ResponseException {
if(response.statusCode != HttpURLConnection.HTTP_OK) {
log.debug response.statusCode
log.debug response.getResponseBodyAsString()
throw new Exception(response.getResponseBodyAsString())
}
}
})
Thanks
Hi!
Have you tried for the full generated page as Confluence storage format. I mean upload attachments, than create 2 pages. Where one is just link to another attachments.
After compare pages, You can regenerate page programmatically with correct link
Cheers,
Gonchik Tsymzhitov
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.