Hi,
I am using Jira Restful API to get the issue status for a specific issue. the returned JSON object contains a full description if the status (Name, Icon, Description, ...).
How can I get only the StatusID to minimize the network traffic?
You can use fields property in your GET request:
{JIRA INSTANCE ADDRESS}/rest/api/latest/issue/ISSUE-1?fields=status
where ISSUE-1 is key of the issue. You will not get only status ID but something like:
{"status":{"self":"https://helpdesk.morosystems.cz/rest/api/2/status/1","description":"Issue is opened","iconUrl":"https://helpdesk.morosystems.cz/images/icons/statuses/open.png","name":"Open","id":"1","statusCategory":{"self":"https://helpdesk.morosystems.cz/rest/api/2/statuscategory/2","id":2,"key":"new","colorName":"blue-gray","name":"To Do"}}}}
I guess response is small enough though :)
Martin
Thank you for your feedback. actually this is what I am doing now but it is not efficient if you have
/rest/api/2/search?jql=project%20=%20ProjectName%20AND%20Application%20=%20ApplicationName&fields=description,issuetype,status
When you have too many results. So I was wondering how to get only the StatusID instead of StatusObject.
Thanks in advance,
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Jimmy, I don't think it is possible. The only possibility is to implement custom REST API with one endpoint or I found script runner allows you to implement simple REST API endpoints:
https://scriptrunner.adaptavist.com/latest/jira/rest-endpoints.html#_configuration
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
It will be the same since the bottleneck is getting data from Jira REST API, so if I implemented my own REST API on top of Jira API, it will be the same since I am still requesting all the information from Jira and ignore what I do not need at my side. it will be more efficient to get what I need only from Jira and not everything.
Do you have any other ideas?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You've misunderstood what the REST endpoint in ScriptRunner does. It allows you to write an endpoint that does what you need it to. You could easily code an endpoint that responds only with the Status ID and nothing else when it is poked with an issue ID.
You don't do any work on your side and a handful of lines of code is going to be far more quick than Jira processing all the fields you ask for and sending back status object you don't want.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you so much for your feedback!
I see you your point! So ScriptRunner is built on top of Jira and I will just use it. however in order for ScriptRunner to work, it has to either consume Jira REST API and truncate the not needed data on its side (in this case it will be useless) or it will have direct access to Jira Database to get only the required information (in this case I will have dependency on Jira Database version and ScriptRunner version).
I was hoping to find something already built in Jira REST API to support this as it does not make sense if I am getting 100 issues with two status, I receive the same object for all the 100 issues. I can just get the StatusID and do the mapping at my end.
Thanks,
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Not quite, it's neither of those approaches. ScriptRunner is an add-on that works within the core of Jira. One of its functions is to provide REST end points. You write code that uses the internal Java API to get the data you need when something pokes that REST endpoint.
Your code is dependent on Jira and ScriptRunner versions, but it's generally quite stable - the last time I had to rewrite my code was because of the significant refactoring Atlassian did between Jira 6 and 7.
It might make sense for your end point to accept a set of issue IDs and respond with something structured like "status 1, these X issues, status 2, these Y issues, etc".
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I appreciate your feedback!
So Jira RET API has no built-in support for such filtration and I have to use additional add-on like ScriptRunner for that? the problem is installing add-on is not that easy at my company and a lot of approvals will be required.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
No. The REST API uses "fields=" as you saw earlier to filter down what fields it sends back for each issue.
The reason we've suggested Script Runner is because you want status IDs rather than status objects, and it might be quicker and easier for you to get groups of issues, rather than a flat list. The built in REST API doesn't do either of those.
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.
Thank you Nic, that's what I thought with script runner. Jimmy, you can always implement your own plugin to provide required functionality if it is easier to use in your company but it will require more effort to do it. So I think the script runner is still the easiest solution.
Martin
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.