How can i POST some formatted comments using JIRA API

Good day, dear Jira Community! Could you tell me please - can i post, using ‘Add comment’ endpoint, formatted comment? For exaple here is my comment.
image

I can get this comment, using API, here is the ‘body’:

           "body": {
                "version": 1,
                "type": "doc",
                "content": [
                    {
                        "type": "paragraph",
                        "content": [
                            {
                                "type": "text",
                                "text": "test comment "
                            },
                            {
                                "type": "text",
                                "text": "bold",
                                "marks": [
                                    {
                                        "type": "strong"
                                    }
                                ]
                            },
                            {
                                "type": "text",
                                "text": " "
                            },
                            {
                                "type": "text",
                                "text": "italic",
                                "marks": [
                                    {
                                        "type": "em"
                                    }
                                ]
                            }
                        ]
                    },
                    {
                        "type": "paragraph",
                        "content": [
                            {
                                "type": "text",
                                "text": "new paragraph "
                            }
                        ]
                    },
                    {
                        "type": "codeBlock",
                        "attrs": {},
                        "content": [
                            {
                                "type": "text",
                                "text": "code"
                            }
                        ]
                    },
                    {
                        "type": "paragraph",
                        "content": [
                            {
                                "type": "text",
                                "text": "test link",
                                "marks": [
                                    {
                                        "type": "link",
                                        "attrs": {
                                            "href": "https://developer.atlassian.com/cloud/jira/platform/rest/v2/api-group-issue-comments/#api-rest-api-2-issue-issueidorkey-comment-post"
                                        }
                                    }
                                ]
                            },
                            {
                                "type": "text",
                                "text": " plain text"
                            }
                        ]
                    }
                ]
            }

Now i am trying to POST this comment, but i response is:

{
    "errorMessages": [],
    "errors": {
        "comment": "Comment body is not valid!"
    }
}

According to the documentation - “body” field in request has to be a “string”.
Is it possible to POST such formatted comment?
Thank You!

v3 of the API says that the body field can be Anything such as ADF formatting.

Can you try this endpoint instead?

https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issue-comments/#api-rest-api-3-issue-issueidorkey-comment-post

2 Likes

Sure, it works with API v3! Thank you, @rwhitbeck !

I could not make it work with the json object but I used the Text Formatting Notation Text Formatting Notation Help - Create and track feature requests for Atlassian products. to solve the problem