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 Sign up to answer
Community showcase
Posted Tuesday in Jira

What modern development practices are at the heart of how your team delivers software?

Hey Community mates! Claire here from the Software Product Marketing team. We all know software development changes rapidly, and it's often tough to keep up. But from our research, we've found the h...

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