Skip to main content
 首页 » 编程设计

python之如何通过父页面标题检索 Confluence 中的所有子页面

2024年10月24日9oomusou

我知道如何在 Confluence 中通过标题检索页面

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

如何在给定父页面标题的情况下检索所有子页面?

请您参考如下方法:

据我所知,您不能通过父页面的标题 搜索子页面。您需要使用 parent 的 Id 进行搜索。

尝试以下方法获取父 ID:

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

如果只有父级的title,需要先发送第二个调用,从title中获取id

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

在 /confluence/rest/api/content 中找不到 Id 和 children,所以这是行不通的:

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"))