Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
0 / 0 points
badges earned

Your Points Tracker
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Creating a page from Jira using Authentication


I'm using Groovy script to create Conflunce pages automatically using ApplicationLink methods:

def confluenceLink = getPrimaryConfluenceLink()

def authenticatedRequestFactory = confluenceLink.createAuthenticatedRequestFactory()

.createRequest(Request.MethodType.PUT, "rest/api/content/" + GetInsightValue(object.getId(), 1101) + "")
.addHeader("Content-Type", "application/json")
.setRequestBody(new JsonBuilder(params).toString())
.execute(new ResponseHandler<Response>() {
void handle(Response response) throws ResponseException {
if(response.statusCode != HttpURLConnection.HTTP_OK) {
throw new Exception(response.getResponseBodyAsString())
} else {
Object page = new JsonSlurper().parseText(response.getResponseBodyAsString())
String pageTitleq = page["id"]

 The documentation page doesn't mention any methods besides execute althogh I've found the other methods' usage online (addHeader, setRequestBody in my case) and used them in my code.

This script was working fine until my company updated security policies and now anonymous page creation/updating is forbidden and I have to add authentication to this script. It should be always one user ("robot") that creates/updates pages so no user input is required. I couldn't find any useful info about  adding auth to the authenticatedRequestFactory type request but the existence of addHeader method and it's parameters that I used imply that I should be fine adding "default" REST auth header.

Question is will it work or will I have to rewrite the whole script using differet request method for Confluence?

2 answers

Hi @Gleb Kartashov ,

have you tried to use

def authenticatedRequestFactory = confluenceLink.createImpersonatingAuthenticatedRequestFactory()


See here for more info.

0 votes

If you will be using this "robot" user, presumably you know its password.

Then I would recommend you use the simpler RESTClient to make your calls.

import com.atlassian.applinks.api.application.confluence.ConfluenceApplicationType
import com.atlassian.sal.api.component.ComponentLocator
import com.atlassian.applinks.api.ApplicationLinkService

def linkService = ComponentLocator.getComponent(ApplicationLinkService)
def confBaseUrl = linkService.getApplicationLinks(ConfluenceApplicationType.class).first().rpcUrl

def restClient = new RESTClient(confBaseUrl)
restClient.auth.basic 'robotUn', 'robotPw'
requestContentType: ContentType.JSON,
path: "rest/api/content/${GetInsightValue(object.getId(), 1101)}",
body: params //no need to build the json, this should do it for you

Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Confluence

Miss the Confluence demos at Team 21? Watch them here!

Phew, Atlassian Team 2021 blew by. With dozens of demos and a handful of keynotes, you may have missed some of the awesome Confluence Cloud sessions. Don't' worry, you can watch them all here or on Y...

235 views 2 6
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you