Hi All,
I am trying to use REST API Calls to Confluence (Data Center version), but cannot figure out how to pass basic authentication in request call.
Below is example code taken from Confluence REST API Documentation.
import requests
import json
url = "https://your-domain.atlassian.net/wiki/rest/api/content"
headers = { "Accept": "application/json" }
response = requests.request( "GET", url, headers=headers ) print(json.dumps(json.loads(response.text), sort_keys=True, indent=4, separators=(",", ": ")))
Below is the python request module code I am using.
import requests
import json
from requests.auth import HTTPBasicAuth
auth = HTTPBasicAuth("username","password")
url = "http://confluenceurl:8090/confluence/rest/api/content"
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=(",", ": ")))
But, I get 404 Response code
(404=Returned if the calling user does not have permission to view the requested content.A schema has not been defined for this response code.)
Thanks in Advance for helping and teaching.