Webhooks get body

Hello everybody, 

I'm trying to use JIRA webhooks, I need to get the JSON body send by JIRA when when an issue has been updated and get the field which is updated.

is it that possible ?

This is a snippet of my descriptor.json

"webhooks": [
			{
				"name": "Hello webhook",
				"event": "jira:issue_updated",
				"url": "/test",
				"excludeBody": false
			}
		]

 

 Best regards

2 answers

1 accepted

This widget could not be displayed.

Hi @Brahim ESSALIH,

If you hadn't found it already this page is useful: https://developer.atlassian.com/jiradev/jira-apis/webhooks#Webhooks-Example:callbackforanissue-relatedevent

What that page says is that during an issue_updated event you should receive a changelog property in the JSON body that contains the description of what changed most recently. The example on that page shows the changelog property looks like:

"changelog": {
        "items": [
            {
                "toString": "A new summary.",
                "to": null,
                "fromString": "What is going on here?????",
                "from": null,
                "fieldtype": "jira",
                "field": "summary"
            },
            {
                "toString": "New Feature",
                "to": "2",
                "fromString": "Improvement",
                "from": "4",
                "fieldtype": "jira",
                "field": "issuetype"
            }
        ],
		"id": 10124
},

I guess if more than on field changed, then the "items" array will contain more than one entry.

Hope that helps, Jon

Thanks @Jon Bevan [Adaptavist]. Can I tell JIRA to send me the key or id of the field too because the name is not very significant. I need to khow what is the id/key of custom field which is has been updated

 

Best regards 

The "field" property contains the field's key if I remember right. So for a custom field it'll be something like "customfield_10931" but for system fields its "summary" or "issuetype" etc

this is the response when I update a costom field

 

"changelog": {
		"id": "27368",
		"items": [
			{
				"field": "Adresse de facturation",
				"fieldtype": "custom",
				"from": null,
				"fromString": "8 lotissement Darbousson",
				"to": null,
				"toString": "8 lotissement Darbousson\r\nhdfgf"
			}
		]
	}

That's annoying! In that case you'll need to use the fields REST API (https://docs.atlassian.com/jira/REST/cloud/#api/2/field-getFields) to retrieve the available fields and then filter through those for the one that matches the name (assuming you don't have duplicate field names).

Here is Atlassian's publicly visible bug report to fix this which you can vote on and watch: https://ecosystem.atlassian.net/browse/ACJIRA-955

ok Thanks @Jon Bevan [Adaptavist]

This widget could not be displayed.

Hi @Jon Bevan [Adaptavist],

I am using jira-python in windows, and I want to try to set up the webhook. Do you have any tutorial that can guide me through? thanks!!

Suggest an answer

Log in or Sign up to answer
Atlassian Summit 2018

Meet the community IRL

Atlassian Summit is an excellent opportunity for in-person support, training, and networking.

Learn more
Community showcase
Posted yesterday in Statuspage

What are your best incident management tips and stories? #HugOps

 👋Community members! Downtime happens. And great incident response takes a village. Teams like Support, Dev, SRE, Ops, IT, and Marketing have to come together to resolve the problem while keep...

60 views 2 3
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you