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.