Hi community,
I'm trying to create a confluence page via Jira Automation and webhooks, where I want to include only the correctly formatted content of the "description" field from Jira, just like when you go to the jira issue copy and then paste the description to a confluence page.
In this first screenshot, you can see a bulleted list in the description field.
This screenshot is my current automation webhook. To explain a bit further, all the "add value to the audit log" actions are only for debugging purposes. The webhook is using the "create page" API endpoint (see the official doc) and works as expected
This is the page that is created via API, and its title is simply made from the issue key and summary. In the "body" section, I'm setting the content of the page that is being created. In this case, I only want the issue description as the content, but I'm using the smart value as you can see in the screenshot ("{{description.urlEncode.replaceAll etc}}")
However, this is how I would like the page to look. I created this page manually and simply copied the description from the jira issue and pasted it
This screenshot includes the log of the automation, where I tried different operations/functions with my smart value:
I'm missing something about the content of the Jira issue description being converted to a format that can't be interpreted correctly by Confluence. I'm also new to REST API and webhooks in general, so maybe I'm missing something obvious
So from a quick test, it looks like {{description}} returns what looks like wiki format. My audit log (which doesn't include linefeeds) shows:
This is a list * A * B * C [https://somejiralink|https://somejiralink|smartcard]
The Confluence API accepts data in wiki format. So I would try this:
"body": {
"storage": {
"value": "{{description}}",
"representation": "wiki"
}
}
Hi @Darryl Lee
unfortunately, using "representation": "wiki" doesn't work with the POST request for the page create endpoint. However, I found some more information about the "Upate page" PUT request here: https://developer.atlassian.com/cloud/confluence/rest/v2/api-group-page/#api-pages-id-put
I will try to find a way to create the page first and then update the page content accordingly, maybe this is a possibility.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Philip Kroos - TEAM XALT - actually the POST can accept wiki just fine. Here's how I was able to create a page with a curl command:
curl --request POST \
--url 'https://MYSITE.atlassian.net/wiki/api/v2/pages' \
--user 'email@example.com:<api_token>' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--data '{
"spaceId": "753666",
"status": "current",
"title": "Test 2",
"parentId": "950274",
"body": {
"representation": "wiki",
"value": "This is a list\n* foo\n* bar\n* C"
}
}'
The \n is a linefeed. I'm gonna see if I can do this with an Automation....
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Ah, needed a bit of encoding. Tested and validated it works:
Custom data:
{
"spaceId": "753666",
"status": "current",
"title": "{{issue.key}} {{issue.summary}}",
"parentId": "950274",
"body": {
"representation": "wiki",
"value": "{{issue.description.jsonEncode}}"
}
}
The example from there is actually {{issue.summary.jsonEncode}}, and now that I think about it, yeah, if you happen to have foreign characters or emojis in your Summaries, then that's probably a good idea.
But mainly I think I needed it to handle the linefeeds.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
This works like a charm, you're my savior! Thank you so much
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.