request.get() for page content and metadata returns 403

Mike Hyde
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!
March 3, 2022

I am attempting to automate some file uploads to a confluence page using python. I have been following this guide and was able to upload the attachment to /rest/api/content/att{ID}, but, I am stuck retrieving the page content and metadata. The code I'm using is:

headers = {"X-Atlassian-Token": "nocheck", "Accept": "application/json"}

page_output = requests.get("https://{base_url}/api/content/{Page_ID}?expand=space, metadata.labels", headers=headers, auth=('user', 'api-token'))

 

I have also tried using the same code without the expand, as well as expand=body.storage,version,space. However, I keep getting a 403 error, even though I am entering my user and api_token. If I put in the same url in the browser, I can see all the data there, just not when I run it in my terminal.

Any thoughts on why I might be getting this error would be greatly appreciated.

1 answer

1 accepted

0 votes
Answer accepted
Mike Hyde
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!
March 4, 2022

So, I think it was an issue with my vpn. New day, fresh login, and now my code is working. I also discovered that I have to have the wiki included in my url. Otherwise, I receive 404 errors...

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events