How make a call for jira-rest api when "/installed" event fire

Hi.

I am developing atlassian connect addon by using atlassian-connect-spring-boot. In here i want to create custom-field when addon is installed into my jira-cloud host. For that i want make a rest call for create new custom-field when "/installed" lifecycle event fire.

I tried to catch "/installed" request by using custom http request Interceptor.  But it never go through this. All other request are gone through as expected. This is the sample code.

@Component
public class RequestInterceptor extends HandlerInterceptorAdapter {

@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object object) throws Exception {

String requestURI = request.getRequestURI();
log.info("preHandle request : " + requestURI + ", method " + request.getMethod());

if ("/installed".equals(requestURI)) {

log.info("/installed preHandle");

try {
log.info("preHandle auth : " + SecurityContextHolder.getContext().getAuthentication().getPrincipal());
} catch (Exception e) {
log.info("/installed preHandle" + e.getMessage());
}

}

return true;

}

@Override
public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object object, Exception arg3)
throws Exception {

String requestURI = request.getRequestURI();
log.info("after request : " + requestURI + ", method " + request.getMethod());

if ("/installed".equals(requestURI)) {

log.info("/installed after");

try {
log.info("after auth : " + SecurityContextHolder.getContext().getAuthentication().getPrincipal());
} catch (Exception e) {
log.info("/installed after" + e.getMessage());
}

}



}


 The "/installed" event is authenticated by current user that's why i want to catch that event. Could you please tell me is there any solution for this or is there any other way to create custom-field when install addon. Thanks.

0 answers

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 ...

2,781 views 11 18
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