Here are my current issues:
1. Why does Atlassian request a site URL if it is only going to state that it doesn't exist? I cut n pasted as well as manually typed the confluence address for my company and the response was it doesn't exist.
2. When I use the Confluence APIs to retrieve page views, the recurring issue is that Confluence can't transform the stream to valid JSON. I have tried the documentation example as well. Here is the error:
HTTP status: 500
{
"data": {
"authorized": true,
"errors": [],
"successful": true,
"valid": true
},
"message": "com.atlassian.confluence.api.service.exceptions.ecosystem.ServiceException: Unable to transform stream to valid JSON ",
"statusCode": 500
}
And here is a very basic code sample trying to test it for a single page ID. Authentication details aren't listed in the sample but assume that yes the API token is correct etc. (works fine for other types of calls).
import json
import requests
from requests.auth import HTTPBasicAuth
page_id = "5723357766"
url = (
f"{BASE_URL}/wiki/rest/api/analytics/"
f"content/{page_id}/views"
)
auth = HTTPBasicAuth(EMAIL, API_TOKEN)
headers = {
"Accept": "application/json"
}
response = requests.request(
"GET",
url,
headers=headers,
auth=auth
)
print("HTTP status:", response.status_code)
try:
print(
json.dumps(
json.loads(response.text),
sort_keys=True,
indent=4,
separators=(",", ": ")
)
)
except json.JSONDecodeError:
print("Response was not valid JSON:")
print(response.text)