Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Confluence python API gives ERROR-415 while updating page.

Debopam Seal
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!
November 20, 2022

I am trying to programmatically update a confluence using the Python API. It is working the get page requests, I am able to retrieve contents from the page using page ID. The problem is for update requests, where it is giving "requests.exceptions.HTTPError: 415 Client Error: for url: https://confluence.<domain_name>.com/rest/api/content/". 

Here is the code that I am using :


confluence = Confluence(
    url='http://confluence.<domain_name>.com',
    token = PAT)
# This request is working, and page_contents is storing all the contents of the requested page
page_contents = confluence.get_page_by_id(page_id='XXXXXXX' expand='body.storage')
data = '<p>This is the new updated text of the page</p>'
# This is the request that is not working
confluence.update_page("XXXXXXX", 'Python Confluence Tests', data)

 

What I've tried :

  • I've tried to create a new page to check if updating that works,
  • http/https to see if that makes any difference
  • I've also tried the REST API, using requests. It gives the same error for PUT requests.

Am I missing something obvious? Any help would be highly appreciated.

 

 

1 answer

0 votes
Fabio Racobaldo [Catworkx]
Community Champion
November 21, 2022

Hi @Debopam Seal ,

welcome to the Atlassian community!

415 means unsupported mediatype so please check if you defined 'Content-Type: application/json' in your call.

Hope this helps,

Fabio

Debopam Seal
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!
November 21, 2022

Hi Fabio. I am using the Python API, which sets the headers itself while sending away the request I guess. From what I understood, it does set the content-type to application/json, so that should not be the issue.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events