Hi Atlassian Experts
I'm trying to create a user macro that can access the JIRA REST API to pull issues into Confluence so I can make attractive report pages. In general I find that the JIRA issues macro and built in reports don't meet my needs. I've been successful at consuming our internal REST APIs in Confluence Macros but I can't seem to make it work with JIRA.
I'm logged into both applications but I get a 401 Unauthorised error when I try to retrieve an issue.
I'd like to use OAUTH in preference to Basic Auth but i don't know much about it. The tutorial page on authenticating via OAUTH was a little over my head. I suppose my confusion lies in the fact that I assumed setting up the link was taking care of the 'OAUTH dance' piece so why would I need to (re?)implement so much functionality to make it work from Confluence?
Thanks in advance for any suggestions!
Community moderators have prevented the ability to post new answers.
Hi Louise,
I recently coded retrieving data from Confluence in JIRA plugin which is pretty the same. I see that classes are not tied to JIRA packages so the the code snippet should work for you:
public static String doStuff(ApplicationLink appLink) { String error = ""; ApplicationLinkRequest applicationLinkRequest = null; ApplicationLinkRequestFactory applicationLinkRequestFactory = appLink .createAuthenticatedRequestFactory(); try { applicationLinkRequest = applicationLinkRequestFactory.createRequest( com.atlassian.sal.api.net.Request.MethodType.POST, YOUR_URL); applicationLinkRequest.addRequestParameters("param1", VAL_1, "param2", VAL_2); applicationLinkRequest.setFollowRedirects(false); // true be default ResponseHandler<Response> responseHandler = new YourCustomResponseHandler<Response>(); // Parse your response in "handle" method of your ResponseHandler implementation applicationLinkRequest.execute(responseHandler); } catch (CredentialsRequiredException e) { error = "Failed, problem with Application Link: " + e.getMessage(); log.error("Failed, problem with Application Link", e); } catch (Exception e) { error = "Failed: " + e.getMessage(); log.error("Failed", e); } return error; }
Hi there
Thanks for your response! I was hoping for a client-side (jquery/ajax) solution though.
We may look into a plugin but I'd really like to do this in a user macro if that's possible. Or maybe there's some reason I shouldn't be doing that?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I do not think it's possible, but to be sure, please post a new question asking if you can reuse configured ApplicationLink via JavaScript to make REST call from Confluence page to JIRA. Maybe someone knows it for sure.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.