You're on your way to the next level! Join the Kudos program to earn points and save your progress.
Level 1: Seed
25 / 150 points
Next: Root
1 badge earned
Challenges come and go, but your rewards stay with you. Do more to earn more!
What goes around comes around! Share the love by gifting kudos to your peers.
Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!
Join now to unlock these features and more
The Atlassian Community can help you and your team get more value out of Atlassian products and practices.
Hi,
I try to fetch the consumed storage of our spaces by using the python script as documented here: https://confluence.atlassian.com/confkb/finding-storage-usage-of-confluence-space-and-page-using-rest-api-1063555292.html
The script is running fine but stops after 25 spaces. I can't find any limiter within the script, so maybe the REST API is limiting.
Can somebody help me out how to fetch all results?
Regards,
Jonny
It seems the python script does not follow the `_next` links, if there are more than 25 results.
I believe the script needs to be modified for this.
Hi There,
is there anyone who has already updated the script?
Thanks
Patrick
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I got the Solution and edited the Script to get 500 results:
# This code sample uses the 'requests' 'json' 'csv' library: import requests import json import csv #INSERT "USER", "TOKEN", "BASE_URL" HERE USER="User" TOKEN="Token" BASE_URL="https://xxxxxxxxx.atlassian.net" with open('per_page.csv', 'w') as pagecsvfile, open('per_space.csv', 'w') as spacecsvfile: perPageWriter = csv.writer(pagecsvfile, delimiter=',', quotechar='|', quoting=csv.QUOTE_MINIMAL) perSpaceWriter = csv.writer(spacecsvfile, delimiter=',', quotechar='|', quoting=csv.QUOTE_MINIMAL) perPageWriter.writerow(['pageid','attachment_size(byte)']) perSpaceWriter.writerow(['space_name','space_key','attachment_size(byte)']) headers = { "Accept": "application/json" } response = requests.request( "GET", BASE_URL + "/wiki/rest/api/space?limit=500", headers=headers, auth=(USER,TOKEN) ) site_attachment_volume = 0 #Get all space keys space_key_results = json.loads(response.text)["results"] for space in space_key_results: space_attachment_volume = 0 #Get related page IDs from space keys response = requests.request( "GET", BASE_URL + "/wiki/rest/api/space/" + space["key"] + "/content", headers=headers, auth=(USER,TOKEN) ) print("Space Key: " + space["key"]) page_results = json.loads(response.text)["page"]["results"] for page in page_results: page_attachment_volume = 0 #Get attachments from each page print(" " + "Page ID: " + page["id"]) response = requests.request( "GET", BASE_URL + "/wiki/rest/api/content/" + page["id"] + "/child/attachment", headers=headers, auth=(USER,TOKEN) ) attachment_results = json.loads(response.text)["results"] for attachment in attachment_results: print(" " + "Attachment Name: " + json.dumps(attachment["title"]) + ", " + json.dumps(attachment["extensions"]["fileSize"]) + " bytes") page_attachment_volume += int(json.dumps(attachment["extensions"]["fileSize"])) space_attachment_volume += page_attachment_volume print(" -->" + "PAGE TOTAL: " + str(page_attachment_volume)) #Write to CSV perPageWriter.writerow([page["id"],str(page_attachment_volume)]) print("\n " + "SPACE TOTAL: " + str(space_attachment_volume) + " bytes") print("----------") #Write to CSV perSpaceWriter.writerow([space["name"],space["key"],str(space_attachment_volume)])
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.