I have the following use case: we use Confluence to document in a specific format the way work is carried out in Jira issues.
In this sense, the Confluence page will more or less contain the same description as the Jira issue.
Right now, we are doing this manually. Whenever I copy content from the Description field of a Jira issue (not while editing it) and I paste it in the Confluence page, the markups are in place and I see the content in Confluence as it is in Jira.
But I want to automate this process, with a webhook sending the issue details to a service which then creates a Confluence page via the REST API, which should contain the same content as the issue Description (an automatic copy-paste, if you want). But, when creating the page via the API, the markup is saved as pure text.
How should I set the body and representation types so that I get the same behaviour and view when using the REST API?
For example, when I copy paste manually, I get this:
----------------------
This issue is created in order to test Bug creation --> Jira Automation --> AWS Lambda --> Confluence API --> AWS Lambda --> Jira API functionality for automatically creating a Confluence page and linking it to the created Bug.
Here is a link to Google dot com, to test it
And here is a user mention: [redacted]
{ "keyString":"this is a JSON formatted piece of code", "keyInteger": 1234, "keyObject": {"innerKey": true} }
This text is preformatted
And here's a picture of a cat, bullet cat:
------------------------
But when I create the page via the API, I get this:
----------------------
<at:declarations /><h1>1 - Problem description</h1><p>This issue is created in order to test Bug creation --> Jira Automation --> AWS Lambda --> Confluence API --> AWS Lambda --> Jira API
functionality for automatically creating a Confluence page and linking it to the created Bug.
Here is a link to Google dot com, to test it
And here is a user mention: [redacted]
Error rendering macro 'code': Invalid value specified for parameter 'lang'
{ "keyString":"this is a JSON formatted piece of code", "keyInteger": 1234, "keyObject": {"innerKey": true} }
This text is preformatted
And here's a picture of a cat, bullet cat:
----------------------
The REST API reference should better explain the body types and representation values for when creating pages via the API.
You have to first convert the content by accessing [1], before creating the page with the content. Then, I create the page as
"body": {
"storage": {
"value": pageContent,
"representation": "storage",
"embeddedContent": []
}
}
[1]: https://developer.atlassian.com/cloud/confluence/rest/#api-contentbody-convert-to-post
Hi Tudor
We launched a new app that allows you to create pages from templates through Jira Workflow post-function and store the Confluence page in a Jira customfield to apply more actions like:
Workflow postfuntions
Workflow conditions
And so much more.
Please give it a try, I believe it would streamline alot of repeated effort on your team
Jira Confluence Workflow Extensions (JCWE)
Give it a try I am confident you'll love it.
If you have any inquires or requests please drop me an email at admin@innovura.io
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Tudor Munteanu,
when creating a page with REST API, you need to the storage format in the "storage" of the "body" section:
"body": { "view": { "value": "", "representation": "view" }, "export_view": { "value": "", "representation": "view" }, "styled_view": { "value": "", "representation": "view" }, "storage": { "value": "", "representation": "view" },
I have taken this code from https://developer.atlassian.com/cloud/confluence/rest/#api-content-post. Have a look at more examples there, I think they should help.
Roman.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Roman, thanks for your feedback!
I have found the answer to my concern. Before creating the page, I need to convert [1] the content to storage format.
For example, what was a <@user mention> in the Jira issue content, after the conversion it becomes
<span> </span><a class="user-hover" style="text-decoration: none;" title="Follow link" href="https://<your_domain>.atlassian.net/secure/ViewProfile.jspa?accountId=<accountID>"><User Display Name></a>:</p>
Content encapsulated in {code} ... {code} becomes encapsulated in
<pre class="code-java">...</pre>
[1]: https://developer.atlassian.com/cloud/confluence/rest/#api-contentbody-convert-to-post
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.