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?
I have the same issue by using pip module.
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)
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.