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
The Atlassian Community can help you and your team get more value out of Atlassian products and practices.
From Jira1 we send post requests to Jira2 when an issue is created using the Automation for Jira plugin. The screenshot of the rule:
Jira2 receives it using another automation rule. Screenshot below:
So in the ScriptRunner script, I try to parse {{webhookData}} using the code below:
ruleContext.renderSmartValues('{{webhookData.fields.attachment}}')
It returns a JSON string without quotes like the example below:
{
self: https://test2.atlassian.net/rest/api/2/attachment/10240,
id: 10240,
filename: image001 (1).png,
author: {
self: https://test2.atlassian.net/rest/api/2/user?accountId=5d978c421d47a50c34d54152,
accountId: 5d978c421d47a50c34d54152,
accountType: atlassian
},
created: 1642631366135,
size: 8854,
mimeType: image/png,
content: https://test2.atlassian.net/rest/api/2/attachment/content/10240
},
{
self: https://test2.atlassian.net/rest/api/2/attachment/10239,
id: 10239,
filename: notes.png,
author: {
self: https://test2.atlassian.net/rest/api/2/user?accountId=5d978c421d47a50c34d54152,
accountId: 5d978c421d47a50c34d54152,
accountType: atlassian
},
created: 1642631367048,
size: 25333,
mimeType: image/png,
content: https://test2.atlassian.net/rest/api/2/attachment/content/10239
}
Is it possible to get correct JSON with quotes like another example below:
{
"self": "https://test2.atlassian.net/rest/api/2/attachment/10240",
"id": 10240,
"filename": "image001 (1).png",
"author": {
"self": "https://test2.atlassian.net/rest/api/2/user?accountId=5d978c421d47a50c34d54152",
"accountId": "5d978c421d47a50c34d54152",
"accountType": "atlassian"
},
"created": 1642631366135,
"size": 8854,
"mimeType": "image/png",
"content": "https://test2.atlassian.net/rest/api/2/attachment/content/10240"
},
{
"self": "https://test2.atlassian.net/rest/api/2/attachment/10239",
"id": 10239,
"filename": "notes.png",
"author": {
"self": "https://test2.atlassian.net/rest/api/2/user?accountId=5d978c421d47a50c34d54152",
"accountId": "5d978c421d47a50c34d54152",
"accountType": "atlassian"
},
"created": 1642631367048,
"size": 25333,
"mimeType": "image/png",
"content": "https://test2.atlassian.net/rest/api/2/attachment/content/10239"
}
Or maybe you know a way how can I retrieve "content" and "filename" of each attachment from JSON without quotes?
Thank you.