How to send tags (storage format) via REST API?
Asked by Edwin B:

Using the REST API documentation, I'm attempting to create a template with some custom formatting. However, any tags I include are added as string literals, instead of being used as a tag.

A very simple example: I created a new (space) template manually via the UI. Getting this template from the REST API, I can see the following body data:

      "body": {    "storage": {      "value": "<at:declarations /><p>Some body content here.</p>",      "representation": "storage"    }  },

I delete said template and attempt to create the template again via a curl call; [using the documentation](https://developer.atlassian.com/cloud/confluence/rest/#api-template-post).

```
curl -k --request POST \ --url 'https://myurl' \
--user '[REMOVED]' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--data '{
? "name": "My Awesome Template",
? "templateType": "page",
? "body": {
??? "storage": {
??????? "value": "<at:declarations /><p>Some body content here.<p>",
??????? "representation": "storage"
????? }
? },
? "description": "Some Description",
? "space": {
??? "key": "someKey"
? }
}'
```

The call returns successfully and a template is created. However, the contents are just the literal string value: "\<at:declarations /\>\<p\>Some body content here.\<p\>". Attempting to use escape sequences (\&'s) results in the same thing. What am I missing?


Answers:
author: Stephen Sifers
body: Hello Edwin and welcome to the Community,

You have a very solid understanding of template and accessing the API for Confluence. I went through your example code and tested on Confluence Server 6.13. I did find a minor issue which may be causing your problem.

When creating the page, I found that your storage format was not closed properly. Here is what you storage value should look like:

```
"value": "<at:declarations /><p>Some body content here.</p>",
```

Here is the entire example call I used:

```
?curl -k --request POST \ --url 'http://confluence.server.com/rest/api/content' \
--user 'user:password' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--data '{
 "name": "My Awesome Template",
 "title": "Template",
 "type": "page",
 "templateType": "page",
 "space":{
 "key":"TEST"
 },
 "body": {
 "storage": {
 "value": "<at:declarations /><p>Some body content here.</p>",
 "representation": "storage"
 }
 },
 "description": "Some Description"
}'
```

![image.png](https://community.atlassian.com/t5/image/serverpage/image-id/41024i65121D203936BBAF/image-dimensions/403x178?v=v2 "image.png")

Please give your CURL call a try again with the value correction and let us know the results. I did confirm on my end it created a page with content (as seen from the screenshot above).

Regards,  
Stephen Sifers

comments: author: Edwin B
body: Unfortunately, closing the paragraph tag did not change the result on my end. I suspect this problem is due to an issue with the version of Confluence I am using (not 6.13), and that you would have not seen string literals on your server even if you had not closed this tag

I have been able to find a workaround by first creating a template and then updating it with the storage format data I want. I certainly don't like, but it works.


Tags: atl-adm

confluence-server

rest-api

server