You're on your way to the next level! Join the Kudos program to earn points and save your progress.
Level 1: Seed
25 / 150 points
Next: Root
1 badge earned
Challenges come and go, but your rewards stay with you. Do more to earn more!
What goes around comes around! Share the love by gifting kudos to your peers.
Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!
Join now to unlock these features and more
I am currently trying to leverage the "Custom data" approach for the "Web request body" for a given Automation trigger event and running into issues producing the "labels" array list of values with quotes ("") around each value:
Scenario #1: "labels" has a single value of "value1":
"labels": [
"{{issue.labels}}"
],
|--> produces for a single value: "value1"
"labels": [
"value1"
],
Scenario #2: "labels" has multiple values of "value1" and "value2":
"labels": [
"{{issue.labels}}"
],
|--> produces both values: "value1" and "value2"
"labels": [
"value1, value2"
],
|-> desired format where each value has quotes ("") around the values:
"labels": [
"value1",
"value2"
],
Attempted this syntax / format:
{{#issue}}"{{labels}}{{^last}}",{{/}}{{/}}
|-> produces this result:
"labels": [
"value1, value2",
],
Let me know if more details would help explain what I am attempting to achieve for multiple labels list.
Your expression has the quotation mark inside of the {{^last}} expression and it should be before that, like this:
{{#issue}}"{{labels}}"{{^last}},{{/}}{{/}}
And...you may not need this, as the asJsonStringArray can do all that for you, including the enclosing brackets:
Kind regards,
Bill
@Bill Sheboy EXCELLENT guidance!....I was able to get the multiple labels properly formatted using that "asJsonStringArray" approach link you shared:
|-> FINAL Custom data format that worked:
"labels": {{issue.labels.asJsonStringArray}},
|-> RESULTING desired formatted values:
"labels": [
"value1",
"value2"
],
FYI: the other suggestion above produced the same un-wanted format:
{{#issue}}"{{labels}}"{{^last}},{{/}}{{/}}
|-> Produced this formatted values:
"labels": [
"value1, value2",
],
Thanks again for the quick response and getting me un-stuck. Will mark this ticket as Resolved/Answered.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Arg...my bad as I answered too quickly: the labels are a list for this context and so that is where iteration is needed for your first version:
{{#issue.labels}}"{{.}}"{{^last}},{{/}}{{/}}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.