pythonrestconfluence

How can I retrieve all the child pages in Confluence by a parent page title?


I know how to retrieve a page in Confluence by its title

res = requests.get(BASE_URL + "/confluence/rest/api/content", params={"title": "parent page title"} , auth=("username", "pass"))

https://developer.atlassian.com/confdev/confluence-rest-api/confluence-rest-api-examples

How can I retrieve all the child pages given a parent page title?


Solution

  • As I see it, you can't search child pages by their parent's title. You need to search with the parent's Id.

    Try the following to get the parent id:

    /rest/api/content/search?cql=title=<parentTitle>
    

    If you only have the parent's title, you need to send a second call first to get the id from the title

    /rest/api/content/search?cql=parent=<parentId>
    

    Id and children cannot be found with /confluence/rest/api/content, so this is not going to work:

    res = requests.get(BASE_URL + "/confluence/rest/api/content", params={"parent": "<parentId>"} , auth=("username", "pass"))
    
    res = requests.get(BASE_URL + "/confluence/rest/api/content", params={"title": "parents title"} , auth=("username", "pass"))