javascriptconfluence-rest-api

Confluence API - Get child pages of parent also filtered by date range


I am trying to get all the child pages from the parent page and also trying to get the filtered results by the date.

I am trying the following query but it is throwing all the child pages but it is not showing the results within the provided date range.

API endpoint:

https://domain-name.atlassian.net/wiki/rest/api/content/search?cql=parent=2342344&created=2021-01-01%20and%20created=2022-01-01

In the results, I am seeing the child pages but I am also seeing the pages created before 2021


Solution

  • Your query is almost right, you just have to use < and > to filter your dates.

    For example, the following (Python) request works for me:

    response = requests.get(
        url="https://jira.<my domain>.com/confu/rest/api/content/search",
        params={
            "cql": "parent=2342344 and created>2021-01-01 and created<2022-12-11"
        },
        headers={"Authorization": "Basic <token>"}
    )
    

    Just make sure your URL encoding is correct. Encoded, it should look like:

    /confu/rest/api/content/search?cql=parent%3D207377670%20and%20created%3E2021-01-01%20and%20created%3C2022-12-11

    You can find documentation here: https://developer.atlassian.com/server/confluence/advanced-searching-using-cql/