Send latest attachment with webhook + what is the format of the POST when using smart value

With a project webhook, I want to send the latest attachment using the smart value {{issue.attachment.last}}.

This works, though the {{issue.attachment.last}} sends the latest in the list, not the latest added…! But I think I have found a work-around for this.

My colleague on the other side (Jira Spoke in ServiceNow), needs to parse and map this to the attachment field in SN. But: the format of the smartvalue inside the JSON load is not valid JSON. The {{issue.attachment.last}} is in a Bean format.

The payload sent from Jira is as follows:

{
"id":"388132",
"attachment":
"SmartAttachmentBean
{source=AttachmentBean
{self='[https://tryg01.atlassian.net/rest/api/2/attachment/298653'](https://tryg01.atlassian.net/rest/api/2/attachment/298653%27), id=298653, filename='V center1_09.png', 
author=UserBean 

Can’t post it all or attach because I am a new user… sigh

The custom data configured as payload is:

{
"id": "{{issue.id}}",
"attachment": "{{issue.attachment.last}}" 
}

The {{issue.id}} is nice and clean, but the attachment is another format.

Hi,

Thanks for reaching out. Unfortunately there isn’t really an easy elegant way to convert the bean into a json parsable format. You would need to manually specify the fields in the payload you are sending, ie

{
"id": "{{issue.id}}",
"attachment": {
  "id": "{{issue.attachment.last.id}}",
  "filename": "{{issue.attachment.last.filename}}",
  "size": "{{issue.attachment.last.size}}",
  etc 
}
}

Apologies for the inconvenience, I have raised an improvement ticket for this here [AUT-2383] - Code Barrel JIRA

Cheers
Sam

Thanks Sam. And thanks for raising an improvement issue.

Can you provide an answer on how to retrieve the latest added attachment on an issue? attacment.last is not enough.

And: is there a possibility to include the link to the attachment in Jira? Otherwise it cannot be retrieved by another system.

Br, Kristoffer