It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How to get other parameters in WebAction while writting and configuring my custom email handler

Sooxin Dec 13, 2018

Hi guys,

I'm writting a new custom mail handler for Jira, and I read this tutorial: Creating a custom email handler for Jira.

All the paramters are sent into "/secure/admin/EditHandlerDetailsUsingParams" and EditHandlerDetailsUsingParamsWebAction will process them.

So I wirite a new WebAction based on "EditHandlerDetailsUsingParamsWebAction" to obtain and process my own parameters. In fron-end, the request body would look like this:

inline: true
decorator: dialog
atl_token: XXXXXXXXXXXXXXXXXXXXXXXXXXXX
params: project=TEST,issuetype=10000,customFieldSettings=10102
forwardEmail:

As you can see, I put all my custom parameters into "params" splited by comma, so I can easily get this in back-end by calling:

protected void copyServiceSettings(JiraServiceContainer serviceContainer) throws ObjectConfigurationException {
this.forwardEmail = serviceContainer.getProperty("forwardEmail");
// obtain parameters in "params"
this.params = serviceContainer.getProperty("handler.params");
}

It works well util I want to pass many parameters, Jira throw an Exeption and tells the length of characters in "param" must < 255.

So I research this and want to know how Jira deal with this, and I find that Jira send parameters one by one, so Jira can void this problem. Jira will send a request while using mail handler "Create a new issue or add a comment to an existing issue" , request body like this:

inline: true
decorator: dialog
detailsJson: {"projectKey":"TEST","issueTypeId":"10000","stripquotes":false,"catchemail":null,"bulk":"ignore","forwardEmail":null,"createusers":true,"notifyusers":true,"ccwatcher":false,"ccassignee":true,"splitregex":null}
atl_token: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
project: TEST
issuetype: 10000
catchemail:
bulk: ignore
forwardEmail:
createusers: true
reporterusername:
notifyusers: true
ccassignee: true

Then I research "com.atlassian.jira.plugins.mail.webwork.EditHandlerDetailsWebAction" , and find Jira also use this method to get all the parameters:

protected void copyServiceSettings(JiraServiceContainer serviceContainer) throws ObjectConfigurationException {
this.forwardEmail = serviceContainer.getProperty("forwardEmail");
// Jira use this call to obtain all parameters in request body
this.params = serviceContainer.getProperty("handler.params");
}

Then I try to send a resquest like this to my WebAction:

inline: true
decorator: dialog
atl_token: XXXXXXXXXXXXXXXXXXXXXXXXXXXX
params: project=TEST,issuetype=10000,customFieldSettings=10102
forwardEmail:
myCustomParam: test_value

Unluckily, I can only get characters in "params", and I try many methods, finally I still cannot get value of "myCustomParam".

So how can I get value of "myCustomParam" in my webaction just like Jira?

I use Jira v7.5 to test.

Thanks!

0 answers

Suggest an answer

Log in or Sign up to answer
This widget could not be displayed.
This widget could not be displayed.
Community showcase
Asked in Jira Ops

I'm John Allspaw, Ask Me Anything about incident analysis and postmortems

I'm John Allspaw, co-founder of   Adaptive Capacity Labs, where we help teams use their incidents to learn and improve. We bring research-driven methods and approaches to drive effective inciden...

10,576 views 23 17
View question

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you