Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

How can I add an attachment to Confluence using authenticatedRequestFactory?

markbutterfield February 6, 2018

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

Suggest an answer

Log in or Sign up to answer
0 votes
BigBabba August 15, 2019

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.

TAGS
AUG Leaders

Atlassian Community Events