Uploaded image for project: 'Jira Cloud'
  1. Jira Cloud
  2. JSWCLOUD-22517

Web request fails to be sent/received via Automation for Jira if payload contains line break and is generated from another instance

XMLWordPrintable

      Issue Summary

      Web request fails to be sent/received via Automation for Jira if payload contains line break and is generated from another Jira Cloud instance

      Steps to Reproduce

      • Create a rule in a Jira Cloud site A that sends a web request with at least the body of the comment using the default A4J Webhook URL; e.g.:
        {
          "issue": "{{issue.key}}",
          "author": "{{issue.comments.last.author.displayName}}",
          "body": "{{issue.comments.last.body}}"
        }
        
      • Create a rule in a Jira Cloud site B that receives the web request above with trigger as When: Incoming Webhook pointing to the respective URL
      • Add a branch to select which issue to add the comment to
      • The action of the rule above should be to add the comment. The important part is to make sure the body is added, but in the customer's case they also added the author as you can see below:
        *{{webhookData.author}}*
        {{webhookData.body}}
        
      • Add a comment to a Jira issue from the site A making sure the rule from site A is triggered and that the comment has at least one line break in it
      • Consequently, site B will receive the web request via webhook and try to process it, yet, because of the line break, the event is missed

      Expected Results

      Rule should be executed as usual and JSON should be adjusted properly in the back-end to preserve the data and have a valid format.

      Actual Results

      JSON format becomes invalid in the back-end and rule is not even triggered

      Workaround

      From the source site, in the rule that sends the web request, make sure to add the following in the body of the comment or field of same type:

      .replace("\n"," \\n")}}"
      

      E.g.:
      Before:

      {
        "issue": "{{issue.key}}",
        "author": "{{issue.comments.last.author.displayName}}",
        "body": "{{issue.comments.last.body}}"
      }
      

      After:

      {
        "issue": "{{issue.key}}",
        "author": "{{issue.comments.last.author.displayName}}",
        "body": "{{issue.comments.last.body.replace("\n"," \\n")}}"
      }
      

              Unassigned Unassigned
              dwoo@atlassian.com Daniel Woo
              Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

                Created:
                Updated:
                Resolved: