Getting an empty value when using the webhookResponse smart value

Platform Notice: Data Center Only - This article only applies to Atlassian products on the Data Center platform.

Note that this KB was created for the Data Center version of the product. Data Center KBs for non-Data-Center-specific features may also work for Server versions of the product, however they have not been tested. Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.

*Except Fisheye and Crucible

Summary

As explained in the documentation Jira Smart Values - Issues, when using the Send Web Request action, it is possible to access data from the Webhook response by using the smart values below:

  • The smart value below will return the entire body of the webhook response:

1 {{webhookResponse.body}}
  • The smart value below will return the content a specific key from the payload, <key_name> being the name of the key:

1 {{webhookResponse.body.<key_name>}}

There can be various situations where either smart value above will return an empty value. The purpose of this KB article is provide the list of the most common reasons why these smart values will be empty.

Solution

Root Cause 1 - The option "wait for response" is not ticked

The Smart Value {{webhookResponse.body}} will not return anything unless the option Wait for response → Delay execution of subsequent rule actions until we've received a response for this webhook (illustrated below) is ticked:

webhook request

If this option is not ticked, the automation rule will not wait until it gets a response from the Webhook, and the Smart Value {{webhookResponse.body}} will be empty, since the rule did not get a chance to populate it.

To prevent this smart value from being empty, you will need to make sure that this option is ticked.

Root Cause 2 - The "Send Web Request" action was executed inside an if block

If the Send Web Request action is executed inside an IF condition from an IF/ELSE block, the Smart Value {{webhookResponse.body}} will be only available inside the IF condition. If this Smart Value is access outside the IF condition, it will be empty.

The screenshot below illustrates this scenario. We can see in the audit logs shown in the screenshot that the same smart value contains data when accessed within the IF condition, while it is empty when accessed outside the IF condition:

Rootcause2

The only way to fix this issue is to:

  • either ensure that the webhookResponse smart value is accessed in the IF block (if the "Send Web Request" action needs to be executed in that block)

  • or to move the "Send Web Request" action outside the IF block

Root Cause 3 - The payload from the webhook payload has an incorrect Content-Type header

The rule that is sending the webhook will only be able to fetch specific key values from the webhook response, if the Content-Type header of the response is set to application/json. If it is set to a different value such as text/html, the smart value {{webhookResponse.body.<key_name>}} will be empty.

The screenshot below illustrates a rule that is trying to fetch the fields of a Jira issue via the Smart Value {{webhookResponse.body.fields}}. This rule is also logging the headers from the Webhook Response by using the smart value {{webhookResponse.headers}} and the full response by using the smart value {{webhookResponse.body}}. As we can see in this example:

  • the Webhook response is not empty

  • the Webhook header shows that an incorrect content type (html/text) is used, while the actual format of the payload is JSON

  • the smart value {{webhookResponse.body.fields}} is empty, which is caused by the fact that the Content-Type header from the response does not match the format of the body of the response

screenshot

To fix this issue, the application that is providing the Webhook response needs to be fixed, so that the Content-Type contains the right format (application/json).

Root Cause 4 - One of the key name in the webhook response has a dot character in it

Some Webhooks might return payload containing key names that have a "dot" character in the middle of it. In the example of payload shown below, we can see that one of the key/property is called "issue.fields":

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 { "expand":"renderedFields,names,schema,operations,editmeta,changelog,versionedRepresentations", "id":"10001", "key":"SCRUM-2", "issue.fields":{ "issuetype":{ "id":"10001", "description":"Created by Jira Software - do not edit or delete. Issue type for a user story.", "name":"Story", "subtask":false }, "timespent":null, "project":{ "id":"10000", "key":"SCRUM", "name":"SCRUM", "projectTypeKey":"software" } } }

If the automation rule uses the smart value {{webhookResponse.body.issue.fields}}, we will get an empty value as shown in the screenshot below:

Rootcause4

To fix this issue, we need to use double-quote characters to fetch the key "issue.fields". Taking the example above, the correct smart value will be:

1 {{webhookResponse.body."issue.fields"}}

Updated on November 13, 2024

Still need help?

The Atlassian Community is here for you.