Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,365,091
Community Members
 
Community Events
168
Community Groups

How can I add an attachment to Confluence using authenticatedRequestFactory?

Edited

I was successful at creating a new page in the Script Console using the authenticatedRequestFactory simular as follows..

def myResponse
//create page

authenticatedRequestFactory
.createRequest(Request.MethodType.POST, "rest/api/content")
.addHeader("Content-Type", "application/json")
.setRequestBody(new JsonBuilder(params).toString())
.execute(new ResponseHandler<Response>() {
@Override
void handle(Response response) throws ResponseException {
if(response.statusCode != HttpURLConnection.HTTP_OK) {
throw new Exception(response.getResponseBodyAsString())
}
else {
myResponse = new JsonSlurper().parseText(response.responseBodyAsString)["page"]["id"]
}
}
})

I have had a real problem trying to add a new attachment to the new page using "rest/api/content/{id}/child/attachment" as I cannot figure out how to add the file to the request as in the format above?

My goal is to create a new Confluence page with attachment for each Jira issue as a post function. Retrieving the attachment from the jira issue is not a problem..just adding it to the newly created confluence page stumps me.

Any help would be greatly appreciated!

1 answer

I would really like to know this as well. Is there a parameter to be added? Did you figure this out, perhaps?

 

The goal here for me is to create a confluence page from a Jira ticket using the tickets description and tickets attachment.

Suggest an answer

Log in or Sign up to answer
TAGS

Atlassian Community Events