Skip to content

Commit 35ad845

Browse files
authored
Improve get_page_id method to return None if no results found (#1667)
1 parent 463f0ad commit 35ad845

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

atlassian/confluence/server/__init__.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -338,13 +338,16 @@ def get_child_pages(self, page_id, **kwargs):
338338

339339
def get_page_id(self, space, title, type="page"):
340340
"""
341-
Provide content id from search result by title and space.
341+
Get page ID by searching for it by space key and title - returns the ID from the first result or None if not found.
342342
:param space: SPACE key
343343
:param title: title
344344
:param type: type of content: Page or Blogpost. Defaults to page
345345
:return:
346346
"""
347-
return (self.get_page_by_title(space, title, type=type) or {}).get("id")
347+
json_response = self.get_page_by_title(space, title, type=type)
348+
if json_response and "results" in json_response and len(json_response["results"]) > 0:
349+
return json_response["results"][0]["id"]
350+
return None
348351

349352
def get_parent_content_id(self, page_id):
350353
"""

0 commit comments

Comments
 (0)