Loss of formatting when updating the issue description using forge, Rest API

Hi everyone, I am working with forge issue panel in Jira cloud, with a requirement to append text to the description field. In order to achieve this the only way I see to update the text is to fetch the existing description from issue using api. Append the new text and use the rest api to update the description

let bodyData = {
      fields: {
        description: formattedMessage,
        labels: ["modified"],
      },
    };
requestJira(route`/rest/api/3/issue/${issueKey}` // to update.

The problem I am plagued with is the update expects me to pass the description as ADF format, but when requesting the text from issue description It is returned in plain text instead of ADF. As a result all the rich text formatting is lost. Please find the screenshots attached to see the issue clearly.

Please advise if I am missing something because I could not find any thing in the documentation to resolve the issue so far.

Welcome to the Atlassian Developer Community, @JitendraSantoshVarma!

Upon checking, calling the Get issue REST API v3 returns the description in ADF format.

Here's the test result I got for reference
    "fields": {
        "description": {
            "version": 1,
            "type": "doc",
            "content": [
                {
                    "type": "paragraph",
                    "content": [
                        {
                            "type": "text",
                            "text": "This is a formatted"
                        }
                    ]
                },
                {
                    "type": "paragraph",
                    "content": [
                        {
                            "type": "text",
                            "text": "text",
                            "marks": [
                                {
                                    "type": "strong"
                                }
                            ]
                        }
                    ]
                },
                {
                    "type": "paragraph",
                    "content": [
                        {
                            "type": "text",
                            "text": "hello world",
                            "marks": [
                                {
                                    "type": "em"
                                }
                            ]
                        }
                    ]
                },
                {
                    "type": "paragraph",
                    "content": [
                        {
                            "type": "text",
                            "text": "bold",
                            "marks": [
                                {
                                    "type": "strong"
                                }
                            ]
                        },
                        {
                            "type": "text",
                            "text": " "
                        },
                        {
                            "type": "text",
                            "text": "with italics",
                            "marks": [
                                {
                                    "type": "em"
                                }
                            ]
                        }
                    ]
                },
                {
                    "type": "paragraph",
                    "content": [
                        {
                            "type": "text",
                            "text": "colored text",
                            "marks": [
                                {
                                    "type": "textColor",
                                    "attrs": {
                                        "color": "#ffc400"
                                    }
                                }
                            ]
                        },
                        {
                            "type": "text",
                            "text": " "
                        }
                    ]
                }
            ]
        }
    }

One scenario I can think of this happening is by using the Get issue REST API v2 which returns the description body as plain text.

Can you share the code snippet on how you are retrieving the issue description as well as the response?

Cheers,
Ian

1 Like