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

Tharanga September 16, 2017

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