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

This widget could not be displayed.

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

 

This widget could not be displayed.

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

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 Wednesday in New to Jira

Are you planning to trial, or are currently trialling Jira Software? - We want to talk to you!

Hello! I'm Rayen, a product manager at Atlassian. My team and I are working hard to improve the trial experience for Jira Software Cloud. We are interested in   talking to 20 people planning t...

137 views 2 0
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