I am trying to get a confluence page, and my final goal is to modify it, but I seem to get a 404 return regardless of what I call. I am using the Jira REST quite a lot, which works fine, but for confluence I have no idea what is wrong.
I have admin privileges to the entire chain of pages and my python code is as follows:
auth = (<myUser>, <myPassword>)
headers = {'Content-Type' : 'application/json'}
url = "https://<myDomain>/confluence/rest/api/content/295789998?expand=body.storage"
response = requests.get(url, auth=auth, headers=headers)
print(response)
which prints:
<Response [404]>
In pure desperation I tried regular curl calls as well, of course with the same result.
I have tried virtually all type of calls found at:
https://developer.atlassian.com/server/confluence/confluence-rest-api-examples/
and they all return 404 (page not found)
All help is much appreciated!
EDIT:
I also tried with an api token as below, and got a 401 error (unauthorized):
import requests
from requests.auth import HTTPBasicAuth
import json
url = "https://<myDomain>/confluence/rest/api/content/295789998?expand=body.storage"
token = "<myAPIToken>"
auth = HTTPBasicAuth(user, token)
headers = {
"Accept": "application/json"
}
response = requests.request(
"GET",
url,
headers=headers,
auth=auth
)
print(json.dumps(json.loads(response.text), sort_keys=True, indent=4, separators=(",", ": ")))
What am I doing wrong?