Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

webhook variables

Renee Gadson
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
May 29, 2015

I am trying to figure out the correct syntax to create an update and delete webhook to communicate with Clarizen when the parameter is workItemId

--Update Webhook----

ex.  http://clarizen-2-jira-prod.cloudhub.io/xxx/jira-issue-updated?issueKey=${issue.key}&${workItemId=customfield_10700}

 

 ----Delete Webhook-----

 ex. http://clarizen-2-jira-prod.cloudhub.io/xxx/jira-issue-deleted?issueKey=${issue.key}&workItemId=${issue.customfield_10700}

 

3 answers

1 vote
Deleted user March 15, 2017

The solution would be language dependent and, I'm sorry, but I don't 'speak' nodejs.

I do speak PHP and this is what I used

// Get the body information and write it to the file
$entityBody = file_get_contents('php://input');
http://php.net/manual/en/function.file-get-contents.php

The trick here is that I'm using "php://input" as the "filename" to get the body.

This returns the body in json format.

I'm sorry, but I don't know how to do it in some other language.

 

1 vote
Deleted user July 28, 2016

I don't think you can. You can only use the variable they list on this page: 

https://developer.atlassian.com/jiradev/jira-apis/webhooks

BUT the good news is that you get a body of the POST request and it has everything about that issue in it, including all the custom fields and their values.

Jeffrey Coleman
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
March 14, 2017

How do you access the body info?

I cannot find much help on the web other than this post, but I only see the variables in my request to server.

Using Nodejs:

exports.webhook = function(req, res) {
var hookURL = "https://hooks.slack.com/services/##########";

res.setHeader('Access-Control-Allow-Origin', '*');
res.setHeader('Access-Control-Allow-Methods', 'GET, POST');
res.setHeader('Access-Control-Allow-Headers', 'X-Requested-With,content-type');
res.setHeader('Access-Control-Allow-Credentials', true);

console.log(req) /// where is all the issue content?
var username = req.query.user_key
var projectkey = req.params.projectkey
var issuekey = req.params.issuekey
var message = "Issue '"+issuekey+"' in project '"+projectkey+"' has been modified by '"+username+"'."
var channel = "yourslackchannel"
var key = req.params.key

if (key && key == "#########################"){
slack = new Slack(hookURL,{
channel: "#"+channel,
username: "Jira Logger",
text: message,
icon_url: "./public/icon.jpg"
});

slack.notify(message, function(err, result){
console.log(err,result);
// res.send(result)
res.send("Sent to Slack: #"+channel+", "+message);
});
}else{
res.send("Unauthorized request");
}

};

 

Deleted user March 15, 2017

It sounds like you are getting the headers but not the body. This looks like it's goal is to get just some minimal info from the headers and send it to slack. I don't see anything here that is parsing jason or looks like it's accessing the body of POST.

Like • Deleted user likes this
0 votes
Marcel Montel April 18, 2016

Did you ever resolve this? Is it possible to send custom parameters to the webhook?

Suggest an answer

Log in or Sign up to answer
TAGS
atlassian, team '25 europe, atlassian event, barcelona 2025, jira, confluence, atlassian intelligence, rovo, ai-powered collaboration, developer tools, agile teams, digital transformation, teamwork solutions, atlassian conference, product announcements

🌆 Team '25 Europe registration is now open!

Join the largest European gathering of the Atlassian Community and reimagine what’s possible when great teams and transformative technology come together. Plus, grab your Super Fan ticket now and save over €1,000 on your pass before prices rise on 3 June.

Register now
AUG Leaders

Atlassian Community Events