Automation breaks REST call

Csaba Vertessy October 16, 2024

Hello Automation Gurus,

I'm facing the following issue: 

Using Webcall I try to pass the Issue Description (multi-line with lists, text formatting, etc.) but the values of the field returns HTML codes or simpley breaks the JSON.

If I only have one line in the Description, the call is executed.

At this point I'm not sure if it is an Automation issue or with the 3rd party.

Here are the bodies of the 3 different approach I'va tried so far:

Description Smart value (as HTML):

--

{"boardId":"650aad035f9a70ef36ed6978", "name":"{{issue.key}}", "description":"{{issueDescription}} ", "versionIds":["{{issue.fixVersions.id}}"], "virtualVersionIds":[], "columnId":"650aad035f9a700032ed696f", "synchronize":false, "synchronizeParams":{"name":true, "description":true, "startDate":true, "releaseDate":true}, "startDate":"{{now.jiraDate}}", "releaseDate":""}

Returns:

{message=Bad control character in string literal in JSON at position 126, stack=SyntaxError: Bad control character in string literal in JSON at position 126 at JSON.parse () at parse (/home/node/app/server/node_modules/body-parser/lib/types/json.js:92:19) at /home/node/app/server/node_modules/body-parser/lib/read.js:128:18 at AsyncResource.runInAsyncScope (node:async_hooks:206:9) at invokeCallback (/home/node/app/server/node_modules/raw-body/index.js:238:16) at done (/home/node/app/server/node_modules/raw-body/index.js:227:7) at IncomingMessage.onEnd (/home/node/app/server/node_modules/raw-body/index.js:287:7) at IncomingMessage.emit (node:events:519:28) at endReadableNT (node:internal/streams/readable:1696:12) at process.processTicksAndRejections (node:internal/process/task_queues:82:21)}

--

Description as text:

--

{"boardId":"650aad035f9a70ef36ed6978", "name":"{{issue.key}}", "description":"{{issue.description.text}}", "versionIds":["{{issue.fixVersions.id}}"], "virtualVersionIds":[], "columnId":"650aad035f9a700032ed696f", "synchronize":false, "synchronizeParams":{"name":true, "description":true, "startDate":true, "releaseDate":true}, "startDate":"{{now.jiraDate}}", "releaseDate":""}

Returns:

{message=Bad control character in string literal in JSON at position 119, stack=SyntaxError: Bad control character in string literal in JSON at position 119 at JSON.parse () at parse (/home/node/app/server/node_modules/body-parser/lib/types/json.js:92:19) at /home/node/app/server/node_modules/body-parser/lib/read.js:128:18 at AsyncResource.runInAsyncScope (node:async_hooks:206:9) at invokeCallback (/home/node/app/server/node_modules/raw-body/index.js:238:16) at done (/home/node/app/server/node_modules/raw-body/index.js:227:7) at IncomingMessage.onEnd (/home/node/app/server/node_modules/raw-body/index.js:287:7) at IncomingMessage.emit (node:events:519:28) at endReadableNT (node:internal/streams/readable:1696:12) at process.processTicksAndRejections (node:internal/process/task_queues:82:21)}

--

Description field:

--

{"boardId":"650aad035f9a70ef36ed6978", "name":"{{issue.key}}", "description":"{{issue.description}}", "versionIds":["{{issue.fixVersions.id}}"], "virtualVersionIds":[], "columnId":"650aad035f9a700032ed696f", "synchronize":false, "synchronizeParams":{"name":true, "description":true, "startDate":true, "releaseDate":true}, "startDate":"{{now.jiraDate}}", "releaseDate":""}

Returns:

{message=Bad control character in string literal in JSON at position 120, stack=SyntaxError: Bad control character in string literal in JSON at position 120 at JSON.parse () at parse (/home/node/app/server/node_modules/body-parser/lib/types/json.js:92:19) at /home/node/app/server/node_modules/body-parser/lib/read.js:128:18 at AsyncResource.runInAsyncScope (node:async_hooks:206:9) at invokeCallback (/home/node/app/server/node_modules/raw-body/index.js:238:16) at done (/home/node/app/server/node_modules/raw-body/index.js:227:7) at IncomingMessage.onEnd (/home/node/app/server/node_modules/raw-body/index.js:287:7) at IncomingMessage.emit (node:events:519:28) at endReadableNT (node:internal/streams/readable:1696:12) at process.processTicksAndRejections (node:internal/process/task_queues:82:21)}

---

Here is a screenshot about the rule:

automation.png

What I have tried:

* changed the field renderer to text instead of wiki markup 

* tried to store the Description in variables (as text or html)

* use single line in description: that worked but it is unreal for a description to have only one line.

Any suggestion on how to proceed? Or help identifying if it is an issue with Automation or with the 3rd party plugin?

Have a nice day!

 

2 answers

1 accepted

0 votes
Answer accepted
Csaba Vertessy October 22, 2024
{{issue.description.html.asJsonString}} 

Did the trick for us to keep the formatting.  

0 votes
Bill Sheboy
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 16, 2024

Hi @Csaba Vertessy 

First thing, to avoid potential rule errors with smart value collisions, I recommend always adding a prefix to variable names, such as varIssueDescription rather than issueDescription.

What does the audit log show when you run your rule?  (I recommend writing those diagnostic messages to the log rather than adding comments to the issue.)

Next, have you tried using the asJsonString function to include the description field in the message: https://support.atlassian.com/cloud-automation/docs/jira-smart-values-json-functions/#asJsonString

Kind regards,
Bill

Csaba Vertessy October 17, 2024

Hi @Bill Sheboy  ,

thanks for your suggestion.

I tried your approach and got this:

TEST Package creation

second line

  • list

COLOR

produces:

TEST Package creation\n\nsecond line\n\n* list\n\nCOLOR

And this is what I got for response:

{message=Expected ',' or '}' after property value in JSON at position 99, stack=SyntaxError: Expected ',' or '}' after property value in JSON at position 99 at JSON.parse (<anonymous>) at parse (/home/node/app/server/node_modules/body-parser/lib/types/json.js:92:19) at /home/node/app/server/node_modules/body-parser/lib/read.js:128:18 at AsyncResource.runInAsyncScope (node:async_hooks:206:9) at invokeCallback (/home/node/app/server/node_modules/raw-body/index.js:238:16) at done (/home/node/app/server/node_modules/raw-body/index.js:227:7) at IncomingMessage.onEnd (/home/node/app/server/node_modules/raw-body/index.js:287:7) at IncomingMessage.emit (node:events:519:28) at endReadableNT (node:internal/streams/readable:1696:12) at process.processTicksAndRejections (node:internal/process/task_queues:82:21)}
At this point I need to contact Atlassian to let them have a look into this as I think there is something wrong with escaping special characters.

Anyway, thanks for yor reply :)

Regards,

Csaba

 

Bill Sheboy
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 17, 2024

Those two do not appear to be related as the text written to the log is not 99 characters long...unless you are embedding in within a JSON expression.

Perhaps posting images your current, complete rule and an image of the audit log details for the rule execution will provide context.

Until then...

I recommend simplifying to test this piece by piece:

  • first, confirm the interface to your service
  • call your service with a tool like Postman to confirm that interface
  • then, simplify your rule to:
    • trigger: manual
    • action: send web request, passing the description as
      • "description" : {{issue.description.asJsonString}}
    • action: log the results, such as the web response status and body
  • and re-test

 

Csaba Vertessy October 18, 2024

Hi @Bill Sheboy ,

this is my rule:

rule.png

This is from the logs:

log.png

Here is the result:

result.png

Let me know what you think.

Regards,

Csaba

Bill Sheboy
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 18, 2024

Thanks for that information, @Csaba Vertessy 

Where are you viewing that result for the "Description" after the second API call?

Does the markdown in that other system match the color syntax the Jira Description field is using: https://jira.atlassian.com/secure/WikiRendererHelpAction.jspa?section=texteffects

 

Csaba Vertessy October 22, 2024

Hi @Bill Sheboy , we were able to keep the expected formatting using 

{{issue.description.html.asJsonString}}

 Thanks for your suggestion!

Like Bill Sheboy likes this

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events