Forums

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

Newline character in HTML causes `UnsupportedOperationException` when updating a page

Andrew Marshall
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!
March 16, 2021

Steps to reproduce - 

def update_with_attachment(page,  space, version):
    data = {
        "type": "page",
        "title": title,
        "id": page,
        "space": {"key": space},
        "body": {
           "storage": {
             "value": '<ac:image><ri:attachment ri:filename="image.png">\n</ri:attachment></ac:image>',
             "representation": "storage"
           }
        },
        "version": {"number": version}
}
response = requests.put(url, json=data, auth=auth)

 

Expected result - 

A 200 Response

 

Actual result - 

com.atlassian.confluence.api.service.exceptions.InternalServerException: java.lang.RuntimeException: com.atlassian.confluence.content.render.xhtml.storage.resource.identifiers.StorageUnmarshalXhtmlException: java.lang.UnsupportedOperationException

 

Workaround:

Remove the newline character from 

<ri:attachment ri:filename="image.png">\n</ri:attachment>

 

1 answer

0 votes
Diego
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
March 18, 2021

Hello there @Andrew Marshall!

As I understand, you need to create a new line after the attachment you created. I also believe that you are trying to do so via REST, is that correct?

The way you added the newline character shows us that the \n was added as if it was inside the attachment structure, not after it.

You can try adding the \n after the attachment structure. You can check more details about REST API here:

Confluence Cloud Developer - Content - attachments

Let us hear from you!

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
TAGS
AUG Leaders

Atlassian Community Events