Hi
I'm using Groovy script to create Conflunce pages automatically using ApplicationLink methods:
def confluenceLink = getPrimaryConfluenceLink()
def authenticatedRequestFactory = confluenceLink.createAuthenticatedRequestFactory()
authenticatedRequestFactory
.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>() {
@Override
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"]
setInsightPageValue(Integer.valueOf(pageTitleq))
log.error('Success!')
}
}
})
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?