Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

how to retrieve contentState history for a specific page id via API?

theo_carvalho
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
June 2, 2023

Hi,

I was wondering if it is possible for a specific page id, to retrieve for each of its content state change, its authorId and date of change.

 

The closest I got was using Get Content Properties for Page (api doc) where I seemed to retrieve the last contentState change. I've noticed that they only show up to 3 events, even if I change the limit parameter

 

Heres's the code
import requests
from requests.auth import HTTPBasicAuth
import json

your_domain = xxx
page_id = xxxx
api_token = xxx


url = f"https://{your_domain}/wiki/api/v2/pages/{page_id}/properties"

auth = HTTPBasicAuth("email", api_token)

headers = {
  "Accept": "application/json"
}

response = requests.request(
   "GET",
   url,
   headers=headers,
   auth=auth, params={"limit":10}
)

response.json()
# print(json.dumps(json.loads(response.text), sort_keys=True, indent=4, separators=(",", ": ")))
'''
Output:
{'results': [{'value': 'v2', 'key': 'editor', 'id': xxx, 'version': {'number': 1, 'message': '', 'minorEdit': False, 'authorId': 'xxxx', 'createdAt': '2023-06-03T00:20:36.036Z'}}, {'value': '{"contentState":{"id":xxx,"color":"#2684ff","name":"Under construction"},"version":5,"isSpaceState":true,"isNewState":false,"setterAAID":"xxxx"}', 'key': 'content-state-published', 'id': xxx, 'version': {'number': 4, 'message': '', 'minorEdit': False, 'authorId': 'xxx', 'createdAt': '2023-06-03T00:37:55.648Z'}}, {'value': '{"contentState":{"id":xxxx,"color":"#2684ff","name":"Under Construction"},"version":4,"isSpaceState":true,"isNewState":false,"setterAAID":"xxx"}', 'key': 'content-state-draft', 'id': xxx, 'version': {'number': 3, 'message': '', 'minorEdit': False, 'authorId': 'xxx', 'createdAt': '2023-06-03T00:37:53.733Z'}}], '_links': {}}
Desired output:
my response comes with the following field:
'_link' : {'next': url-cursor-key-number-here'}
I'm also open to other ways as long it uses API.

1 answer

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
TAGS
AUG Leaders

Atlassian Community Events