Add content ids to REST API storage objects
Asked by Iffy M:

I'm relatively new to using the confluence REST API and have been having issues with attributes in my HTML content being dropped when uploaded to the page.

For example, if I uploaded the following

\<table id="my_table_1"\>  
\<tr\>  
\<th\>Company\</th\>  
\<th\>Contact\</th\>  
\<th\>Country\</th\>  
\</tr\>  
\<tr\>  
\<td\>Centro comercial Moctezuma\</td\>  
\<td\>Francisco Chang\</td\>  
\<td\>Mexico\</td\>  
\</tr\>  
\</table\>

The content uploaded to the confluence page (which I get from making another pull from the page) drops the id attribute:

\<table border="1"\>  
\<tr\>  
\<th\>Company\</th\>  
\<th\>Contact\</th\>  
\<th\>Country\</th\>  
\</tr\>  
\<tr\>  
\<td\>Centro comercial Moctezuma\</td\>  
\<td\>Francisco Chang\</td\>  
\<td\>Mexico\</td\>  
\</tr\>  
\</table\>

I know this is because confluence uses their own storage format called 'XHTML' (<https://confluence.atlassian.com/doc/confluence-storage-format-790796544.html>).

So is there any way to add an ID to an XHTML storage object? Or is there a storage object we can use to ID other storage objects?

Any help is appreciated


Answers:
author: David Bakkers
body: Hello [@Iffy M](/t5/user/viewprofilepage/user-id/4649048)

In short, the answer is no. When you submit HTML as content, it is parsed by Confluence and sanitised, and some element attributes, like IDs, are stripped out.

You could tag the table as a [resource](https://confluence.atlassian.com/doc/confluence-storage-format-790796544.html#ConfluenceStorageFormat-Resourceidentifiers):

```
<ri:content-entity ri:content-id="my_table_1"/>
```

That sort of content identification works within Confluence pages, but not in the more generic context that you may be looking for.

comments: author: Iffy M
body: Hi [@David Bakkers](/t5/user/viewprofilepage/user-id/1575730)

Thank you for the information, I actually tried to use resource content ids but I wasnt able to get it working, it was sanitized from the input

Would it be

```
<ri:content-entity ri:content-id="my_table_1"/>
<table border="1">
<tr>
    <th>Company</th>
    <th>Contact</th>
    <th>Country</th>
  </tr>
  <tr>
    <td>Centro comercial Moctezuma</td>
    <td>Francisco Chang</td>
    <td>Mexico</td>
  </tr>
</table>
```

Or would you have to wrap the table with resource identifier?


author: David Bakkers
body: Hi [@Iffy M](/t5/user/viewprofilepage/user-id/4649048)

IIRC, you put the content information inside the definition of the table:

```
<table border="1" ri:content-entity ri:content-id="my_table_1">
```

I haven't done this for quite some time, since I moved over to Confluence Cloud and submitting content in ADF format, not HTML or markup, so I'm a bit rusty.

Which leads me to the next question. How, exactly, are you submitting HTML content to Confluence Cloud? That link you provided to [Confluence Storage Format](https://confluence.atlassian.com/doc/confluence-storage-format-790796544.html) is for Confluence SERVER. Are you sure you're on Confluence CLOUD not SERVER / DATACENTER?


author: Iffy M
body: Hi [@David Bakkers](/t5/user/viewprofilepage/user-id/1575730)

Thank you for the help, I didn't realize thats how it was included in the object, I'll try that and see if it works.

I believe I am on the confluence cloud, based on what I was told when I was setting up my account (according to Atlassian, confluence clouds have an https://).

Also to mention that the script I am working on was already uploading content properly, I just wanted to figure out how to add content IDs to items.

Edit: I just tried to make the upload and was given a 400 Client Error


Tags: cloud

confluence-cloud

html

rest-api