Forums

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

REST API. Find the page by title pattern.

krivonos February 23, 2022

Hi all,

Please, give me an idea how to find the page by pattern using REST API. For example, in the SQL query i could write: PageTitle like 'Report%' and I'll find pages with titles 'Report2021', 'Report2022' etc.

I tried to use REST API with asterix symbol like that:

http://mysite:myport/rest/api/content/?title=REPORT*&spaceKey=TESTSPACE

No result :(

Thanks in advance.

1 answer

0 votes
Sunny Ape
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.
February 24, 2022

Hello @krivonos 

CQL is not the same syntax as SQL. There are lots of mistakes in the URL you've provided as your example:

  1. REST API endpoints do not end with a backslash before the question mark (to denote the start of declaring any parameters)
  2. Ampersands (&) are not used to join CQL clauses. The joining keyword is "AND"
  3. You can only use the wildcard (*) character with the Contains (~) operator
  4. If you do use the wildcard character, you must enclose the text to search for with quotation marks
  5. CQL is case sensitive, so REPORT != Report

I would suggest you spend some time re-reading the Confluence CQL documentation and looking at the examples to get a better understanding of how to construct properly formed CQL queries.

krivonos February 27, 2022

David, thanks for your answer.

That did work for  me:

http://mysite:myport/rest/api/content/search?cql=(title~"REPORT*")&(spaceKey=TESTSPACE)

Like Jonny Polivka likes this

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events