my code looks like this:
import requests
from requests.auth import HTTPBasicAuth
contentApiUrl = '/rest/api/content'
# Change these based on your instance
confluenceBaseUrl = 'https://confluence.abc......'
pageId = '26586726'
username = '****'
password = '*****'
requestUrl = '{confluenceBaseUrl}{contentApiUrl}/{pageId}/?expand=body.storage'.format(confluenceBaseUrl = confluenceBaseUrl, contentApiUrl = contentApiUrl, pageId = pageId)
print (requestUrl)
requestResponse = requests.get(requestUrl, auth=HTTPBasicAuth(username, password))
print(requestResponse)
print(requestResponse.content)
output:
<Response [404]>
b'{"statusCode":404,"data":{"authorized":false,"valid":true,"allowedInReadOnlyMode":true,"errors":[],"successful":false},"message":"No content found wit
h id: ContentId{id=26586726}","reason":"Not Found"}'
The pageId , userid and password is correct.
but the catch is when i hit the url mentioned in requestUrl through browser it return the JSON but when i call the url through it gives 404 error.
Hi @shantanu kumar ,
Please confirm that you have access to the page. The documentation states:
STATUS 404 - Returned if there is no content with the given id, or if the calling user does not have permission to view the content.
@Edwin Kyalangalilwa yes, I can access the confluence page through browser.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.