Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Python API conf.update_page fails with simple HTML

Edited

Using PIP module atlassian-python-api

The following fails with error
requests.exceptions.HTTPError: com.atlassian.confluence.api.service.exceptions.BadRequestException: Content body cannot be converted to new editor format

from atlassian import Confluence
conf = Confluence(url=conf_site, username=CONF_USER, password=CONF_TOKEN)
page_id = conf.get_page_id(page_space, page_title)
page = conf.get_page_by_id(page_id, expand="body.storage")
page_content = page["body"]["storage"]["value"]

html_table = "<table>Prod version updated<table />"
conf.update_page(page_id, page_title, html_table)

 Similar code block to passing case also fails:

from atlassian import Confluence
conf = Confluence(url=conf_site, username=CONF_USER, password=CONF_TOKEN)
page_id = conf.get_page_id(page_space, page_title)
page = conf.get_page_by_id(page_id, expand="body.storage")
page_content = page["body"]["storage"]["value"]

html_table = "Prod version updated</table>"
conf.update_page(page_id, page_title, html_table)

However this does not:

from atlassian import Confluence
conf = Confluence(url=conf_site, username=CONF_USER, password=CONF_TOKEN)
page_id = conf.get_page_id(page_space, page_title)
page = conf.get_page_by_id(page_id, expand="body.storage")
page_content = page["body"]["storage"]["value"]

html_table = "Prod version updated<table />"
conf.update_page(page_id, page_title, html_table)

 

The code is valid HTML. What is wrong here? 

2 comments

I get the same error when directly using requests.put:

{"statusCode":400,"data":{"authorized":false,"valid":true,"errors":[],"successful":false},"message":"com.atlassian.confluence.api.service.exceptions.BadRequestException: Content body cannot be converted to new editor format"}

 

version += 1
html_table = "Prod version updated<table></table>"
data = {
"type": page_type,
"title": page_title,
"version": {"number": version},
"body": {"storage": {"value": html_table, "representation": "storage"}},
}

response = requests.put(
f"{content_url}/{page_id}",
headers=HEADERS,
auth=(CONF_USER, CONF_TOKEN),
json=data,
)
print(response.content)

I have the same issue by using pip module.

Comment

Log in or Sign up to comment
TAGS
AUG Leaders

Atlassian Community Events