I set up the requestbin and changed the URL in the webhook. I added the /${issue.key} to see what it would return. All I got on in the requestbin was “ok” - nothing else. What am I missing? Why is nothing else coming out of JIRA?
RequestBin is very picky about URLs. Appending to the path won’t work. But you can use a query parameter. For example, I just configured to send a webhoook on every issue update to http://requestb.in/1hieuil1?issueId=${issue.id}
. When I changed an issue, here’s what I got:
So my question then is where do I find out what the JIRA webbook looks like?
The JIRA docs on webhooks have examples, you just have to open some of the sections that say “Show me” (sorry for the poor doc design, we’re switching to having all code examples in visible blocks, not hidden). But, for reference, here’s what I received in RequestBin:
{
"timestamp": 1490819671963,
"webhookEvent": "jira:issue_updated",
"issue_event_type_name": "issue_updated",
"user": {
"self": "https://devpartisan.atlassian.net/rest/api/2/user?username=admin",
"name": "admin",
"key": "admin",
"emailAddress": "ibuchanan@atlassian.com",
"avatarUrls": {
"48x48": "https://secure.gravatar.com/avatar/7581132d18239f9356e14a82c84da336?d=mm&s=48",
"24x24": "https://secure.gravatar.com/avatar/7581132d18239f9356e14a82c84da336?d=mm&s=24",
"16x16": "https://secure.gravatar.com/avatar/7581132d18239f9356e14a82c84da336?d=mm&s=16",
"32x32": "https://secure.gravatar.com/avatar/7581132d18239f9356e14a82c84da336?d=mm&s=32"
},
"displayName": "Ian Buchanan [Administrator]",
"active": true,
"timeZone": "America/Chicago"
},
"issue": {
"id": "10010",
"self": "https://devpartisan.atlassian.net/rest/api/2/issue/10010",
"key": "TIS-11",
"fields": {
"issuetype": {
"self": "https://devpartisan.atlassian.net/rest/api/2/issuetype/10002",
"id": "10002",
"description": "The sub-task of the issue",
"iconUrl": "https://devpartisan.atlassian.net/secure/viewavatar?size=xsmall&avatarId=10316&avatarType=issuetype",
"name": "Sub-task",
"subtask": true,
"avatarId": 10316
},
"parent": {
"id": "10009",
"key": "TIS-10",
"self": "https://devpartisan.atlassian.net/rest/api/2/issue/10009",
"fields": {
"summary": "As a developer, I can update story and task status with drag and drop (click the triangle at far left of this story to show sub-tasks)",
"status": {
"self": "https://devpartisan.atlassian.net/rest/api/2/status/3",
"description": "This issue is being actively worked on at the moment by the assignee.",
"iconUrl": "https://devpartisan.atlassian.net/images/icons/statuses/inprogress.png",
"name": "In Progress",
"id": "3",
"statusCategory": {
"self": "https://devpartisan.atlassian.net/rest/api/2/statuscategory/4",
"id": 4,
"key": "indeterminate",
"colorName": "yellow",
"name": "In Progress"
}
},
"priority": {
"self": "https://devpartisan.atlassian.net/rest/api/2/priority/3",
"iconUrl": "https://devpartisan.atlassian.net/images/icons/priorities/medium.svg",
"name": "Medium",
"id": "3"
},
"issuetype": {
"self": "https://devpartisan.atlassian.net/rest/api/2/issuetype/10000",
"id": "10000",
"description": "A user story. Created by JIRA Software - do not edit or delete.",
"iconUrl": "https://devpartisan.atlassian.net/images/icons/issuetypes/story.svg",
"name": "Story",
"subtask": false
}
}
},
"timespent": null,
"project": {
"self": "https://devpartisan.atlassian.net/rest/api/2/project/10000",
"id": "10000",
"key": "TIS",
"name": "Teams in Space",
"avatarUrls": {
"48x48": "https://devpartisan.atlassian.net/secure/projectavatar?avatarId=10324",
"24x24": "https://devpartisan.atlassian.net/secure/projectavatar?size=small&avatarId=10324",
"16x16": "https://devpartisan.atlassian.net/secure/projectavatar?size=xsmall&avatarId=10324",
"32x32": "https://devpartisan.atlassian.net/secure/projectavatar?size=medium&avatarId=10324"
}
},
"fixVersions": [{
"self": "https://devpartisan.atlassian.net/rest/api/2/version/10001",
"id": "10001",
"name": "Version 2.0",
"archived": false,
"released": false,
"releaseDate": "2016-09-15"
}],
"aggregatetimespent": null,
"resolution": null,
"customfield_10310": null,
"customfield_10311": null,
"customfield_10312": null,
"customfield_10027": null,
"customfield_10302": null,
"customfield_10303": null,
"customfield_10304": null,
"customfield_10305": null,
"customfield_10306": null,
"customfield_10307": null,
"customfield_10308": null,
"resolutiondate": null,
"customfield_10309": null,
"workratio": -1,
"lastViewed": "2017-03-29T15:34:13.929-0500",
"watches": {
"self": "https://devpartisan.atlassian.net/rest/api/2/issue/TIS-11/watchers",
"watchCount": 0,
"isWatching": false
},
"created": "2016-09-04T14:47:29.278-0500",
"customfield_10021": ["com.atlassian.greenhopper.service.sprint.Sprint@af21bd[id=1,rapidViewId=1,state=ACTIVE,name=Sample Sprint 2,goal=<null>,startDate=2016-09-01T02:45:31.321-05:00,endDate=2016-09-15T03:05:31.322-05:00,completeDate=<null>,sequence=1]"],
"customfield_10022": "0|i00027:",
"priority": {
"self": "https://devpartisan.atlassian.net/rest/api/2/priority/4",
"iconUrl": "https://devpartisan.atlassian.net/images/icons/priorities/low.svg",
"name": "Low",
"id": "4"
},
"customfield_10100": null,
"customfield_10023": null,
"customfield_10024": [],
"customfield_10300": null,
"customfield_10025": null,
"customfield_10301": null,
"customfield_10026": null,
"labels": [],
"customfield_10016": null,
"customfield_10017": null,
"timeestimate": null,
"aggregatetimeoriginalestimate": null,
"versions": [],
"issuelinks": [],
"assignee": {
"self": "https://devpartisan.atlassian.net/rest/api/2/user?username=admin",
"name": "admin",
"key": "admin",
"emailAddress": "ibuchanan@atlassian.com",
"avatarUrls": {
"48x48": "https://secure.gravatar.com/avatar/7581132d18239f9356e14a82c84da336?d=mm&s=48",
"24x24": "https://secure.gravatar.com/avatar/7581132d18239f9356e14a82c84da336?d=mm&s=24",
"16x16": "https://secure.gravatar.com/avatar/7581132d18239f9356e14a82c84da336?d=mm&s=16",
"32x32": "https://secure.gravatar.com/avatar/7581132d18239f9356e14a82c84da336?d=mm&s=32"
},
"displayName": "Ian Buchanan [Administrator]",
"active": true,
"timeZone": "America/Chicago"
},
"updated": "2017-03-29T15:34:31.796-0500",
"status": {
"self": "https://devpartisan.atlassian.net/rest/api/2/status/3",
"description": "This issue is being actively worked on at the moment by the assignee.",
"iconUrl": "https://devpartisan.atlassian.net/images/icons/statuses/inprogress.png",
"name": "In Progress",
"id": "3",
"statusCategory": {
"self": "https://devpartisan.atlassian.net/rest/api/2/statuscategory/4",
"id": 4,
"key": "indeterminate",
"colorName": "yellow",
"name": "In Progress"
}
},
"components": [],
"timeoriginalestimate": null,
"description": null,
"customfield_10010": null,
"customfield_10011": null,
"customfield_10012": null,
"customfield_10013": null,
"customfield_10014": "Not started",
"timetracking": {},
"customfield_10005": null,
"customfield_10006": null,
"customfield_10007": null,
"customfield_10008": null,
"attachment": [],
"customfield_10009": null,
"aggregatetimeestimate": null,
"summary": "Update task status by dragging and dropping from column to column >> Try dragging this task to \"Done\"",
"creator": {
"self": "https://devpartisan.atlassian.net/rest/api/2/user?username=admin",
"name": "admin",
"key": "admin",
"emailAddress": "ibuchanan@atlassian.com",
"avatarUrls": {
"48x48": "https://secure.gravatar.com/avatar/7581132d18239f9356e14a82c84da336?d=mm&s=48",
"24x24": "https://secure.gravatar.com/avatar/7581132d18239f9356e14a82c84da336?d=mm&s=24",
"16x16": "https://secure.gravatar.com/avatar/7581132d18239f9356e14a82c84da336?d=mm&s=16",
"32x32": "https://secure.gravatar.com/avatar/7581132d18239f9356e14a82c84da336?d=mm&s=32"
},
"displayName": "Ian Buchanan [Administrator]",
"active": true,
"timeZone": "America/Chicago"
},
"subtasks": [],
"reporter": {
"self": "https://devpartisan.atlassian.net/rest/api/2/user?username=admin",
"name": "admin",
"key": "admin",
"emailAddress": "ibuchanan@atlassian.com",
"avatarUrls": {
"48x48": "https://secure.gravatar.com/avatar/7581132d18239f9356e14a82c84da336?d=mm&s=48",
"24x24": "https://secure.gravatar.com/avatar/7581132d18239f9356e14a82c84da336?d=mm&s=24",
"16x16": "https://secure.gravatar.com/avatar/7581132d18239f9356e14a82c84da336?d=mm&s=16",
"32x32": "https://secure.gravatar.com/avatar/7581132d18239f9356e14a82c84da336?d=mm&s=32"
},
"displayName": "Ian Buchanan [Administrator]",
"active": true,
"timeZone": "America/Chicago"
},
"customfield_10000": null,
"aggregateprogress": {
"progress": 0,
"total": 0
},
"customfield_10001": null,
"customfield_10320": null,
"customfield_10200": null,
"customfield_10003": "{}",
"customfield_10313": null,
"customfield_10314": null,
"customfield_10315": null,
"environment": null,
"customfield_10316": null,
"customfield_10317": null,
"customfield_10318": null,
"duedate": null,
"customfield_10319": null,
"progress": {
"progress": 0,
"total": 0
},
"comment": {
"comments": [{
"self": "https://devpartisan.atlassian.net/rest/api/2/issue/10010/comment/10002",
"id": "10002",
"author": {
"self": "https://devpartisan.atlassian.net/rest/api/2/user?username=admin",
"name": "admin",
"key": "admin",
"emailAddress": "ibuchanan@atlassian.com",
"avatarUrls": {
"48x48": "https://secure.gravatar.com/avatar/7581132d18239f9356e14a82c84da336?d=mm&s=48",
"24x24": "https://secure.gravatar.com/avatar/7581132d18239f9356e14a82c84da336?d=mm&s=24",
"16x16": "https://secure.gravatar.com/avatar/7581132d18239f9356e14a82c84da336?d=mm&s=16",
"32x32": "https://secure.gravatar.com/avatar/7581132d18239f9356e14a82c84da336?d=mm&s=32"
},
"displayName": "Ian Buchanan [Administrator]",
"active": true,
"timeZone": "America/Chicago"
},
"body": "To Do to In Progress 3 days 21 hours 8 minutes ago",
"updateAuthor": {
"self": "https://devpartisan.atlassian.net/rest/api/2/user?username=admin",
"name": "admin",
"key": "admin",
"emailAddress": "ibuchanan@atlassian.com",
"avatarUrls": {
"48x48": "https://secure.gravatar.com/avatar/7581132d18239f9356e14a82c84da336?d=mm&s=48",
"24x24": "https://secure.gravatar.com/avatar/7581132d18239f9356e14a82c84da336?d=mm&s=24",
"16x16": "https://secure.gravatar.com/avatar/7581132d18239f9356e14a82c84da336?d=mm&s=16",
"32x32": "https://secure.gravatar.com/avatar/7581132d18239f9356e14a82c84da336?d=mm&s=32"
},
"displayName": "Ian Buchanan [Administrator]",
"active": true,
"timeZone": "America/Chicago"
},
"created": "2016-09-04T14:47:29.277-0500",
"updated": "2016-09-04T14:47:29.277-0500"
}],
"maxResults": 1,
"total": 1,
"startAt": 0
},
"votes": {
"self": "https://devpartisan.atlassian.net/rest/api/2/issue/TIS-11/votes",
"votes": 0,
"hasVoted": false
},
"worklog": {
"startAt": 0,
"maxResults": 20,
"total": 0,
"worklogs": []
}
}
},
"changelog": {
"id": "11400",
"items": [{
"field": "priority",
"fieldtype": "jira",
"from": "3",
"fromString": "Medium",
"to": "4",
"toString": "Low"
}]
}
}
How do I set up my receiver to get the webhook data from JIRA?
Although I’ve done a fair bit of C#, it’s been a couple years. For that matter, I never wrote a WebHookHandler
. However, I can’t help but wonder if adding the issue to the path was a problem for your code, just like it was for RequestBin. Removing the conditional and all assumptions about the shape of the context
, maybe something like the following will start to yield more insights (sorry, I don’t have an environment for running this, so consider it more psuedo-code.)
public class JiraHandler : WebHookHandler
{
public override Task ExecuteAsync(string receiver, WebHookHandlerContext context)
{
Console.Write(receiver);
JObject data = context.GetDataOrDefault<JObject>();
Console.Write(data);
return Task.FromResult(true);
}
}
Once we get this worked out, I hope you’ll post your working source code as an open-source project. It would be a great help to have such a project for reference!