Hi,
I am trying to update a confluence page using Python. I have tried the curl examples that are here in the community forums, but struggling with python.
I am getting 405 and am guessing I have something malformed.
Any help will be greatly appreciated!
print ("NEW PAGE: \n" + new_page)
print ("Updating page @ " + dataAPI)
headers = {'Content-type': 'application/json', 'Accept' : 'application/json'}
result = requests.post(dataAPI, auth=HTTPBasicAuth(username, password), verify=False, json=new_page, headers=headers )
print (result)
Getting Confluence Page Version number
Retriving from https://XXXXXXXX.XXX.XXXX.XXX/confluence/rest/api/content/376006486
old_version : 15, new_version : 16
NEW PAGE:
{"id":"376006486","type":"page","title":"Patterns Summary Data","space":{"key":"XXXXXXX"},"body":{"storage":{"value":"<ac:structured-macro ac:name=\"chart\" ac:schema-version=\"1\" ac:macro-id=\"304d2585-1d15-4851-8867-90bcb2c2c926\"><ac:parameter ac:name=\"dataOrientation\">vertical</ac:parameter><ac:rich-text-body><table class=\"wrapped\" style=\"text-align: left;\"><colgroup><col /><col /></colgroup><tbody><tr><th style=\"text-align: left;\"><p>All Time Status</p></th><th style=\"text-align: left;\"><p>count of Patterns</p></th></tr><tr><td style=\"text-align: left;\"><p>ARCHIVED</p></td> <td style=\"text-align: left;\"><p>1</p></td></tr><tr><td style=\"text-align: left;\"><p>ENDORSED</p></td> <td style=\"text-align: left;\"><p>19</p></td></tr><tr><td style=\"text-align: left;\"><p>PROPOSED</p></td> <td style=\"text-align: left;\"><p>6</p></td></tr><tr><td style=\"text-align: left;\"><p>SOCIALISED</p></td> <td style=\"text-align: left;\"><p>13</p></td></tr><tr><td style=\"text-align: left;\"><p>UNDER DEVELOPMENT</p></td> <td style=\"text-align: left;\"><p>14</p></td></tr><tr><td style=\"text-align: left;\"><p>WITHDRAWN</p></td> <td style=\"text-align: left;\"><p>5</p></td></tr></tbody></table></ac:rich-text-body></ac:structured-macro><p><br /></p>","representation":"storage"}},"version":{"number":16}}}
Updating page @ https://XXXXXXXX.XXX.XXXX.XXX/confluence/rest/api/content/376006486
<Response [405]>
Error : 405
You can do it, like this as well
https://github.com/atlassian-api/atlassian-python-api/blob/master/atlassian/confluence.py#L465
Finally figured it out.
Should be requests.put, (not request.post)
I've obviously been looking at it for too long!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Jarrod, You seemed to have coded something that I just started looking and that is updating a page which has a confluence macro. It seems I have not figured out the correct python code for the insertion of <ac:structured........ I wonder whether you would be kind enough to share that part of the python code?
Thanks
Peter
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.