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.
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?
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"
}'
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
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.