getting json error when updating the confluence page

Deleted user April 20, 2021

Currently I'm getting this error when I tried to update the confluence page.
error: HTTP RESONPONSE 500

this is my code:
################
import re
import bs4
import requests

headers={'Content-Type': 'application/json','Authorization': 'Basic token'}
dataurl='https://page/wiki/rest/api/content/1212121212?expand=body.storage'

contentx = requests.get(address, headers=headers).json()
content=contentx['body']['storage']['value']
regex = re.compile(r"<td>i need to update this</td>")
new_content = regex.sub("<td>updated</td>", content)

soupx = bs4.BeautifulSoup(new_content, features="html.parser")
soup=str(soupx)
payload={'id':'121212121212,'type':'page','title':'testing12121212','space':{'key':'space'},"body":{"storage":{"value":soup,"representation":"storage"}},'version':{'number':2}}
##########

i couldn't find what is the issue.
can someone help on this

1 answer

0 votes
Elifcan Cakmak
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 21, 2021

Hello,

First of all I can't see where you do the update. Is this the whole script?

Second, check if the get works without a problem. Return contentx and see what it says. You should see which line you get the error.

Regards,

Elifcan

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events