简体   繁体   中英

Escape values in webhook's JSON payload in Automation for JIRA

I have a webhook action configured using Code Barrel's Automation for JIRA add-on. It sends a request to an endpoint that expects a JSON payload.

Using the templating syntax, I can write a custom body like

{"some_key": "{{issue.summary}}"}

to template values into the JSON payload:

该图以“发送webhook”形式显示了上述模板

However, this is fragile; if any of the templated values contain a double quote or a backslash, we're likely to generate a syntactically invalid JSON payload.

Is there any way in Automation for JIRA to escape text for inclusion within a JSON string?

I just did a quick release that enables you to encode these values. You can find the docs at - https://docs.codebarrel.io/automation/smart-fields/working-with-strings.html#encoding

Though it is pretty simple:

{"some_key": "{{issue.summary.jsonEncode}}"}

This is live in Cloud and available in version 3.9.7 in Server.

Hope that is what you were after.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM