Error when creating a page via the REST API: "Error parsing xhtml: Unexpected close tag </xml>
Asked by Edwin B:

I'm attempting to create a page via the REST API; specifically, the [Create Content resource](https://developer.atlassian.com/cloud/confluence/rest/#api-content-post). However, when submitting data with html tags, I receive the following error about an expected closing xml tag, despite having no such tag defined.

Example message I am sending via POST:

```
{
? "title" : "Some Page",
? "type" : "page",
? "space" : {
??? "key" : "US"
? },
? "body" : {
??? "storage" : {
????? "representation" : "storage",
????? "value" : "<h2>Lorem ipsum dolor sit</h2><table><tr><td>Lorem</td><td>Ipsum</td></tr><tr><td>Lorem ipsum dolor</td><td>Lorem ipsum d</td></tr><tr><td>Lorem ipsum dolor sit amet, consect</td><td>Lorem</td></tr><tr><td>Lorem ipsum dolor sit</td><td>Lorem ipsum</td></tr><tr><td>Lorem ipsum dolor sit amet, consectetur adipiscing</td><td>Lorem ipsum</td></tr><tr><td>Lorem ipsum dolor sit amet, consectetur</td><td>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</td></tr><tr><td>Lorem ipsum dolor sit amet, consectetur</td><td>Lorem</td></tr><tr><td>Lorem ipsum dolor sit amet, consectetur</td><td>Lorem ipsum dolor</td></tr><tr><td>Lorem ipsum dolor sit amet, consectetur</td><td>Lorem</td></tr></table>"
??? }
? }
}
```

The response I receive from Confluence:

```
{
? "statusCode":400,
? "data":
? {
??? "authorized":false,
??? "valid":true,
??? "allowedInReadOnlyMode":true,
??? "errors":[],
??? "successful":false
? },
? "message":"Error parsing xhtml: Unexpected close tag </xml>; expected </td>.\n at [row,col {unknown-source}]: [10,2271]",
? "reason":"Bad Request"
}
```

The value I'm sending formatted for easier viewing:

```
<h2>Lorem ipsum dolor sit</h2>
<table>
?? ?<tr>
?? ??? ?<td>Lorem</td>
?? ??? ?<td>Ipsum</td>
?? ?</tr>
?? ?<tr>
?? ??? ?<td>Lorem ipsum dolor</td>
?? ??? ?<td>Lorem ipsum d</td>
?? ?</tr>
?? ?<tr>
?? ??? ?<td>Lorem ipsum dolor sit amet, consect</td>
?? ??? ?<td>Lorem</td>
?? ?</tr>
?? ?<tr>
?? ??? ?<td>Lorem ipsum dolor sit</td>
?? ??? ?<td>Lorem ipsum</td>
?? ?</tr>
?? ?<tr>
?? ??? ?<td>Lorem ipsum dolor sit amet, consectetur adipiscing</td>
?? ??? ?<td>Lorem ipsum</td>
?? ?</tr>
?? ?<tr>
?? ??? ?<td>Lorem ipsum dolor sit amet, consectetur</td>
?? ??? ?<td>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</td>
?? ?</tr>
?? ?<tr>
?? ??? ?<td>Lorem ipsum dolor sit amet, consectetur</td>
?? ??? ?<td>Lorem</td>
?? ?</tr>
?? ?<tr>
?? ??? ?<td>Lorem ipsum dolor sit amet, consectetur</td>
?? ??? ?<td>Lorem ipsum dolor</td>
?? ?</tr>
?? ?<tr>
?? ??? ?<td>Lorem ipsum dolor sit amet, consectetur</td>
?? ??? ?<td>Lorem</td>
?? ?</tr>
</table>
```

I've confirmed that removing all the tags resolves the issue, but that is not a workable solution. By replacing the largest table cell with something much shorter, the problem goes away. Again, not a workable solution.

Any suggestions would be appreciated.


Answers:
author: Florian Maupas
body: How are you sending your request ?


author: Zak Laughton
body: Not sure why it would be doing this, but it looks like the content you are trying to send is being cut off. The syntax error is located at column 2271, which falls between the \<td\> and "Lorem" in the second-to-last Lorem Ipsum group.

So it looks like where you're trying to send...

```
...
<td>Lorem ipsum dolor sit amet, consectetur</td>
...
```

...Confluence is actually receiving:

```
...
<td></xml>
```

In some quick research, I couldn't find any known issues with a character limit when sending API requests to Confluence. Is there something in the way you're sending the request that may be cutting off the full request?


Tags: confluence-server

rest-api

server