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
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Julia Dillon
Posted Tuesday in Jira

Tell us how your team runs on Jira!

Hey Atlassian Community! Today we are launching a bunch of customer stories about the amazing work teams, like Dropbox and Twilio, are doing with Jira. You can check out the stories here. The thi...

233 views 1 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