atlassian-api / atlassian-python-api

Atlassian Python REST API wrapper
https://atlassian-python-api.readthedocs.io
Apache License 2.0
1.34k stars 661 forks source link

[Confluence] how to retrieve the page version #1197

Closed nnako closed 1 year ago

nnako commented 1 year ago

When reading pages using the function get_page_child_by_type()" (this would most likely be the case for other functions as well), the parameterexpand` might be used to state which metadata / page properties are to be retrieved. Now, reading pages with the following setting:

children = list(confluence.get_page_child_by_type(
    "1608095605",
    type="page",
    start=None,
    limit=None,
    expand="body.storage,history,version,extensions.inlineProperties",
    ))

returns the expected page(s) but when looking at the metadata at the end of the page structures, there is no concrete version and no concrete history information:

...,
            'representation': 'storage',
            '_expandable': {'content': '/rest/api/content/1608095605'}
        },
        '_expandable': {'editor': '', 'view': '', 'export_view': '', 'styled_view': '', 'anonymous_export_view': ''}
    },
    'extensions': {'position': 'none'},
    '_links': {'webui': '/display/TITLE', 'edit': '/pages/resumedraft.action?draftId=1608095605&draftShareId=4eba0f35-9a1e-44b8-b9e1-cae8ce4f337b', 'tinyui': '/x/dZfZXw', 'self': 'https://URL/confluence/rest/api/content/1608095605'},
    '_expandable': {
        'container': '/rest/api/space/MAINKEY',
        'metadata': '',
        'operations': '',
        'children': '/rest/api/content/1608095605/child',
        'restrictions': '/rest/api/content/1608095605/restriction/byOperation',
        'history': '/rest/api/content/1608095605/history',
        'ancestors': '',
        'version': '',
        'descendants': '/rest/api/content/1608095605/descendant',
        'space': '/rest/api/space/AGIL'
    }
}

Putting the "version" value into the expand parameter, I would have expected the version field of the returned page to hold the value "9", as the version history accessed via GUI shows exactly this.

Is there a way to retrieve the current page's version while reading the page data? Am I doing something stupid here?

nnako commented 1 year ago

sorry. my bad ;-) . the function mentioned is working properly. just looked at the wrong place within my own code.