Given a page, how can I retrieve all its child pages via the rest api?
Now I'm trying to do this but it doesn't work properly. It should return one child page, but it returns 20. Actually, it returns the pages on the same level of hierarachy as the parent page also. And also the parent pages of the parent page.
p1 = {"title": "parent page title"} r1 = requests.get(config.SITE_URL + "/confluence/rest/api/content", params=p1, auth=(config.USERNAME, config.PASSWORD)) pp_id = r1.json()["results"][0]["id"] # parent id # doesn't work properly # p2 = {"parent": pp_id} p2 = {"ancestors":[{"type": "page", "id": pp_id}]} # p2 = {} r2 = requests.get(config.SITE_URL + "/confluence/rest/api/content", params=p2, auth=(config.USERNAME, config.PASSWORD)) # r2 = requests.get(config.SITE_URL + "/confluence/rest/api/content/" + str(pp_id), params=p2, auth=(config.USERNAME, config.PASSWORD)) # r2 = requests.get(config.SITE_URL + "/confluence/rest/api/content/" + str(pp_id) +"?type=page&expand=descendant", params=p2, auth=(config.USERNAME, config.PASSWORD)) # r2 = requests.get(config.SITE_URL + "/confluence/rest/api/content/" + str(pp_id) + "/descendant", params=p2, auth=(config.USERNAME, config.PASSWORD))
Community moderators have prevented the ability to post new answers.
Hi,
Try the follwing, to get the parent id:
/rest/api/content/search?cql=title=<parentTitle>
If you only have the parents 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"))
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.