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

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


1 badge earned


Participate in fun challenges

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


Gift kudos to your peers

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


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!


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
Community Members
Community Events
Community Groups

Confluence Server REST API Search with ScriptRunner


I have a problem with searching pages in Confluence. I executing my request from Jira by scriptrunner:

private checkIfPageExist(String pageName, confluenceLink)
def status = false;
log.error "checkIfPageExist pageName: "+pageName

if(pageName.contains(" "))
pageName = pageName.replace(" ","%20")

def authenticatedRequestFactory = confluenceLink.createImpersonatingAuthenticatedRequestFactory()
.createRequest(Request.MethodType.GET, "/rest/api/content/search?cql=title=%22${pageName}%22")
.addHeader("Content-Type", "application/json")
.execute(new ResponseHandler<Response>() {
void handle(Response response) throws ResponseException {
if(response.statusCode != HttpURLConnection.HTTP_OK) {
throw new Exception(response.getResponseBodyAsString())
else {
log.error "response: "+response.getResponseBodyAsString()
def resp = new JsonSlurper().parseText(response.responseBodyAsString)
if(resp.results.title[0].toString().toLowerCase() == pageName.toLowerCase())
status = true;
catch(Exception ex)
log.error "Error: ${ex}"
return status


I have created page in Confluence with name "Test". In my problematic case this function trying to find page with name "test". Function returns false because search engine does not recognize the size of characters.
But another function in my code is resposible for creating page and creating fail because Confluence returns information that page with the same name exist.

How can I provide recognizing size of characters in searching via API in Confluence?

2 answers

I to am attempt to connect to Confluence Server from our Jira Server using this approach.

However, I am getting a 'nonce used' error when attempt to execute my confluence search.

The error stack is below. 

Per it appears we can no longer use this approach to execute calls against Confluence from Jira.  Is this known?  Would anyone happen to know a workaround if it even exists?  Obviously this approach is preferred versus having to make REST calls and hard code credentials or even an auth token into the script. And to head off the likely question I've tried with my application link set to both 'oauth' and 'oauth with impersonation', same results...

java.lang.Exception: oauth_problem=nonce_used at Script1150$1.handle(Script1150.groovy:42) at com.atlassian.applinks.oauth.auth.OAuthResponseHandler.handle( at$1.handle( at$1.handle( at$2.handle( at at at at com.atlassian.applinks.core.auth.ApplicationLinkRequestAdaptor.execute( at com.atlassian.applinks.oauth.auth.OAuthResponseHandler.handle( at$1.handle( at$1.handle( at$2.handle( at at at at com.atlassian.applinks.core.auth.ApplicationLinkRequestAdaptor.execute( at com.atlassian.applinks.oauth.auth.OAuthRequest.execute( at$execute$ Source) at Script1150.findConfluencePages(Script1150.groovy:38) at

0 votes
Jonny Carter
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.
Dec 10, 2020

Hey, @Paweł Jakimiak ! So, I think the problem is caused because your are searching for titles using the EQUALS operator, which is case sensitive. If you want to do a case insensitive search, you should use the CONTAINS operator.

So, instead of


use a URL like


That will find pages regardless of case.

That said, your check on this line:

if(resp.results.title[0].toString().toLowerCase() == pageName.toLowerCase())

may need a little work if you use the CONTAINS (~) operator. That will only check that the first result in your search results matches your pageName variable. That may not be the case if you use the CONTAINS operator, since that will find more results. You might want something more like:

if (resp.results.any { it.toString().toLowerCase() == pageName.toLowerCase() })

to see if any of the pages returned have the same name, regardless of case, as using the CONTAINS operator is likely to yield many more results than EQUALS.

For more information, check out the Operators reference in the CQL docs.

Suggest an answer

Log in or Sign up to answer
AUG Leaders

Atlassian Community Events