webhook sends empty POST

Hello,

I'm facing a problem with a webhook deployed via add-on json descriptor. I need to receive notifications when JIRA issue is being updated.

 

I use the following command to start local JIRA:

atlas-run-standalone --product jira --version 7.0.0-OD-01-193 --bundled-plugins com.atlassian.bundles:json-schema-validator-atlassian-bundle:1.0.4,com.atlassian.webhooks:atlassian-webhooks-plugin:2.0.0,com.atlassian.jwt:jwt-plugin:1.2.2,com.atlassian.upm:atlassian-universal-plugin-manager-plugin:2.19.1.2-D20150723T232127,com.atlassian.plugins:atlassian-connect-plugin:1.1.44 --jvmargs -Datlassian.upm.on.demand=true 

 

If I use the following format:

"webhooks": [
     {     
           "event": "jira:issue_updated",
           "url": "/jiranotifier.rest"
     }
]

 

Then the request sent to my add-on has empty POST data and 2 fields in query string user_id and admin.

Adding "params" parameter as described on https://developer.atlassian.com/static/connect/docs/1.1.33/modules/common/webhook.html like this:

"webhooks": [
     {     
           "event": "jira:issue_updated",
           "url": "/jiranotifier.rest",

                        "params": {

                               "issue": "${issue.key}"

                        }

     }
]

doesn't help. The POST data is still empty.

 

If I try to do something like this:

 

"webhooks": [
     {     
           "event": "jira:issue_updated",
           "url": "/jiranotifier.rest?issue=${issue.key}"
     }
]

Then I get exception during deployment of the plugin and the root cause is that the url is not validated as correct URI because of $ sign. If I omit dollar sign, then it complaints about the { sign.

 

I tried to configure Webhooks in JIRA administration console, and the following syntax was OK:

/jiranotifier.rest?issue=${issue.key}

However, with that approach, the JWT token was not transmitted.

 

So, how can I describe my add-on in json descriptor so that I'd get key of the JIRA issue that is beeing changed?

Thanks,

Vladimir

 

 

 

2 answers

Well, I don't fully understand why it works, but I managed to solve it this way in Spring @Controller class:

 

HttpServletRequest request ...

String requestContent = IOUtils.toString(request.getInputStream(), "UTF-8");
JSONObject jo =  return new JSONObject(requestContent);

 

The populated jo object contained all the data that I expected to be POST-ed


Perhaps, JIRA was making a different type of request, not POST or GET...

Vladimir

 

0 vote

Have you tried using the Webhook inspector to see what is happening? https://bitbucket.org/atlassianlabs/webhook-inspector

Suggest an answer

Log in or Join to answer
Community showcase
Sarah Schuster
Posted Jan 29, 2018 in Jira

What are common themes you've seen across successful & failed Jira Software implementations?

Hey everyone! My name is Sarah Schuster, and I'm a Customer Success Manager in Atlassian specializing in Jira Software Cloud. Over the next few weeks I will be posting discussion topics (8 total) to ...

3,322 views 14 20
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
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot