Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

how to copy a jira issue description to a Confluence page

Philip Kroos - TEAM XALT
Contributor
September 24, 2024

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.

Screenshot 2024-09-24 at 14.46.06.png

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

Screenshot 2024-09-24 at 14.47.21.png

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}}")

 

Screenshot 2024-09-24 at 14.46.19.png

 

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 

Screenshot 2024-09-24 at 14.46.29.png

This screenshot includes the log of the automation, where I tried different operations/functions with my smart value:

Screenshot 2024-09-24 at 14.48.01.png

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

1 answer

1 accepted

2 votes
Answer accepted
Darryl Lee
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
September 24, 2024

Hi @Philip Kroos - TEAM XALT 

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"
}
}
Philip Kroos - TEAM XALT
Contributor
September 25, 2024

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. 

Darryl Lee
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
September 25, 2024

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"
  }
}'

Screenshot 2024-09-25 at 9.06.55 PM.png

The \n is a linefeed. I'm gonna see if I can do this with an Automation....

Darryl Lee
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
September 25, 2024

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.

Like # people like this
Philip Kroos - TEAM XALT
Contributor
September 25, 2024

This works like a charm, you're my savior! Thank you so much 

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events