Jira Script Runner update issue description with HTML

132 Views Asked by At

I am writing a script to remove signatures from description using Script Runner. My workflow: fetch issue description HTML using renderedFields

def issueDescription = get("/rest/api/2/issue/${issueKey}?expand=renderedFields")
        .asObject(Map)
        .body
        .renderedFields["description"] as String

Having the description in HTML I have removed the signature pattern. Now I have my description without the signature but in a string containing HTML tags.

How to update the issue?

I tried to use simple put for a description field:

put("/rest/api/2/issue/${issueKey}?expand=renderedFields")
                .header('Content-Type', 'application/json')
                .body([
                    fields: [
                        description: updatedDesription
                    ]
                ])
                .asString()

As expected I have now visible HTML tags in my ticket. I also tried something similar like I did my get request (renderedFields)

put("/rest/api/2/issue/${issueKey}?expand=renderedFields")
                .header('Content-Type', 'application/json')
                .body([
                    renderedFields: [
                        description: updatedDesription
                    ]
                ])
                .asString()

With the same results. Is there a parameter to inform that the value is a raw HTML and need to rendered or there is a nice way to render back the value before calling put ?

0

There are 0 best solutions below