Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How to access content in confluence from scriptrunner for jira cloud?

Janco Hoekstra August 22, 2025

I need to access json data that is stored in a Confluence page and use this in Scriptrunner for Jira cloud as a json map.
When I try to access the api endpoint of Confluence  for the page, I get 'unauthorized'.

I tried both possible settings: run script as scriptrunner user and tried it as my own user.
Same result for both cases.

I can't use a normal request as on datacenter with authentication setup. this is predefined in Scriptrunner for cloud, by the setting above (Scriptrunner Add-on user or current user) 

How can I access this json data in Confluence or get authenticated using a service user?

1 answer

1 accepted

1 vote
Answer accepted
Matteo Vecchiato
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 22, 2025

Hi @Janco Hoekstra ,

Thank you for your question.

Have you tried to specify the basic authorization?

From Scriptrunner for Jira Cloud it could be used the following piece of script to read a Confluence page:

 def pageBody = get("https://<mysite>.atlassian.net/wiki/rest/api/content/<page_id>?expand=body.view")
.basicAuth(USER_SERVICE_EMAIL, USER_TOKEN)
.asString()
.getBody()

The key is to specify the .basicAuth function with email and token variable.
In this case it returns an html, so it is required to parse the pageBody variable in order to get the page content required.

You can use the v2 api with this method: https://developer.atlassian.com/cloud/confluence/rest/v2/api-group-page/#api-pages-id-get 

Another option is what described in the following tutorial from Scriptrunner here: https://www.scriptrunnerhq.com/help/example-scripts/create-confluence-page-for-issues-cloud  (please keep attention in the "Good to know" section that specify: "This snippet requires that you have both ScriptRunner for Jira Cloud and ScriptRunner for Confluence Cloud installed. If you do not have ScriptRunner for Confluence Cloud installed, you will need to update this example to specify user credentials to access the Confluence instance."

 

I suggest to use a service account, as referenced here: https://support.atlassian.com/user-management/docs/understand-service-accounts/ 

I hope it helps and please flag the reply if useful.

Kind regards

Janco Hoekstra August 25, 2025

Thanks Matteo,

This works perfect! you gave me just the information that I needed and could not find anywhere.
I did not stumble across the .basicAuth(USER_SERVICE_EMAIL, USER_TOKEN) parameter to the request in cloud.
I thought that from scriptrunner, these parameters where set to current user or the scriptrunner application user and where not settable in the script.
I tested it and it gave me just what I need.

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
ENTERPRISE
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events