Hi there,
I want to get the data from the SLA on my JIRA plugin.
The way I'm trying to do this is by using the rest service.
Here is an example of my code:
String baseUrl = System.getProperty("baseurl"); String resourceUrl = baseUrl + "/rest/servicedesk/1/servicedesk/sla/issue/"+issue.getKey(); DefaultHttpClient client = new DefaultHttpClient(); HttpGet request = new HttpGet(resourceUrl); try { HttpResponse response = client.execute(request); } catch (IOException e) { e.printStackTrace(); }
The output of my code is:
[INFO] [talledLocalContainer] Client must be authenticated to access this resource.
Is there any way to pass the authentication to the HttpClient?
Is this the better way of getting the sla of an issue?
Community moderators have prevented the ability to post new answers.
As you've already discovered, calling REST APIs from the server side is not that easy due to the authentication complications - you have several options if you want to stick with that:
Since your code is running inside an add-on in JIRA, a much simpler approach for me is to you use the Service Desk java API instead - it looks like it has what you need. Check out the SlaInformationService interface javadoc. You'll need to get hold of the SlaInformationServiceInterface instance, construct a SlaInformationQuery via the builder and call SlaInformationService.getInfo().
I have gone other way, instead of trying to use the rest api inside JIRA add-on (Java) I have renitente a par of my code to use it on the client side of the api (javascript).
The Service Desk java API is to much confusing, so I try to avoid it.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yes, that's a good way to do it as well.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I need to create a rest client inside Jira plugin too,
I have a question about your last comment:
When you say: "I have renitente a par of my code to use it on the client side of the api (javascript)"
What do you mean? Could you please provide more info about this? :)
Thank you!!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The point is that besides quering the api on the java side where you need authentication you can querie it on the client side using the credentials that are loged on jira.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.