My request is quite similar to this one - I need to use the Confluence API to get metadata entered in multiple Confluence pages within a folder, except I'm writing a python script instead of using CQL.
I'm attempting to write a script that will scan all the pages (within the Operations Analytics folder, and within the embedded folders) for the Process Review date [and if the date has passed then the "Process Owner(s)" will receive an email.]
I can't figure out how to call the API to scan each individual page within the folder - I can only get the script to read the contents of a single page.
Someone provided an extremely helpful python script in this post that - unlike this script, I don't need to make updates to the pages in any way, I only need to get and read the data. I'm wondering if anyone can provide assistance with the script, or if anyone has written a similar script in Python to what I'm trying to accomplish? Thank you in advance.
I didn't wrote exactly what you need, but I could provide a snippet of my script.
This script would get the content of a single page:
import requests, json
import urllib3
import time
import getpass
url = 'URL'
user = 'USER' # input("Gibt dein Username an: ")
password = 'PW' # getpass.getpass("Gib dein Passwort an: ")
# -------------------------------------------------
headers = {
'X-Atlassian-Token': 'no-check',
'Content-Type': 'application/json'
}
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
auth = (user, password)
page = requests.get(url + '/rest/api/content/' + CONTENT_ID), auth=auth, verify=False).json()
print(page[title])
I also wrote a little method to get all pages recursive:
url_request = self.url + '/rest/api/content/'+page_id+'/child/page'
pages = requests.get(url_request, auth=self.auth, verify=False).json()
for page in pages['results']:
if not page['title'].startswith('.'):
resultpages.append(page)
print("Seite '" + str(page['title']) + " ("+str(page['id'])+")' wurde zum Array hinzugefügt.")
self.getAllDescendantsWithIdRecursive(page['id'], resultpages)
return resultpages
Hope this helps a little bit.
Regards, Dominic
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.