how to copy a jira issue description to a Confluence page
Asked by Philip Kroos - TEAM XALT:

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](https://community.atlassian.com/t5/image/serverpage/image-id/348993iC7718EFA0F6CEB6F/image-size/large?v=v2&px=999 "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](https://developer.atlassian.com/cloud/confluence/rest/v2/api-group-page/#api-pages-post)) and works as expected

![Screenshot 2024-09-24 at 14.47.21.png](https://community.atlassian.com/t5/image/serverpage/image-id/348992i2DFE09B07555F380/image-size/large?v=v2&px=999 "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](https://community.atlassian.com/t5/image/serverpage/image-id/348994i9C8766A646F078E1/image-size/large?v=v2&px=999 "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](https://community.atlassian.com/t5/image/serverpage/image-id/348991i7AD1F7174564D9BF/image-size/large?v=v2&px=999 "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](https://community.atlassian.com/t5/image/serverpage/image-id/348995i14E8DFDB25D2F1F6/image-size/large?v=v2&px=999 "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


Answers:
author: Darryl Lee
body: Hi [@Philip Kroos - TEAM XALT](/t5/user/viewprofilepage/user-id/3965067)

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

comments: author: Philip Kroos - TEAM XALT
body: Hi [@Darryl Lee](/t5/user/viewprofilepage/user-id/1365322)

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.


author: Darryl Lee
body: Hi [@Philip Kroos - TEAM XALT](/t5/user/viewprofilepage/user-id/3965067) - 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](https://community.atlassian.com/t5/image/serverpage/image-id/349398i0003C25F2A16B722/image-size/large?v=v2&px=999 "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....


author: Darryl Lee
body: 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}}"
  }
}
```

* [jsonEncode() documentation](https://support.atlassian.com/cloud-automation/docs/jira-smart-values-text-fields/#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.


author: Philip Kroos - TEAM XALT
body: This works like a charm, you're my savior! Thank you so much


Tags: api

confluence-cloud

jira-cloud

rest-api

webhook