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

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

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,558,898
Community Members
 
Community Events
184
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
AUG Leaders

Atlassian Community Events