Currently I have pages titled in the format
<company_page_id> - <.page description>
As time goes by the <.page description> may be changed based on a central database but the <company_page_id> is constant.
As such I needed to use the API search for pages that start with <company_page_id>. The only way I could make this work was using cql but when the title is returned it is truncated. See below
def get_page_using_id_cql(title_filter: str) -> dict:
cql = f"type = page and {title_filter} order by title"
res = confluence.cql(
cql,
start=0,
limit=100,
expand=True,
include_archived_spaces=None,
excerpt=None,
)["results"][0]
return res['content']['title']
def get_pages_by_title_wildcard_cql(title_filter: str) -> dict:
cql = f'type = page and title ~ "{title_filter}" order by title'
res = confluence.cql(
cql,
start=0,
limit=100,
expand=True,
include_archived_spaces=None,
excerpt=None,
)["results"]
# Filter results that start with wildcard query
res = [
x['content']['title'] for x in res
if x['content']['title'].startswith(title_filter)
]
if res:
return res[0]
return ""
def get_page_by_id(pageid):
res = confluence.get_page_by_id(pageid)
return res['title']
page_id = <confluence_id>
company_page_id = "The quick"
print(get_page_using_id_cql(f'id = "{page_id}"'))
print(get_page_by_id(page_id))
print(get_pages_by_title_wildcard_cql(company_page_id))
for the page shown in image below
this results in
The quick brown fox jumps over the lazy dog abcdefghijklmnopqrstuvwxyz lorem ipsum dolor sit amet, consecteturadipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore
The quick brown fox jumps over the lazy dog abcdefghijklmnopqrstuvwxyz lorem ipsum dolor sit amet, consecteturadipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore
The quick brown fox jumps over the lazy dog abcdefghijklmnopqrstuvwxyz lorem ipsum dolor sit amet, consecteturadipiscing
The first two functions search using Confluence page id and the titles are complete
The third function searched by title using a substring and the returned title is truncated
Am I missing something?
Cheers for any input