I have a point in my code where I want to get an issue's id given it's key.
I'm successfully using the `/issue/{key}` endpoint to do so, but wondered if there was a way to prevent all fields from being returned. I have no need for them in this case.
I've tried passing in a empty string to the "field" param, but it falls back to the default (all fields).
For now I've restricted it to just returning the summary field, but it feels like there should be a way to not have any fields return at all.
Is there such a way?
Hi @Christopher Marriott and welcome!
If you pass an invalid value to the fields param, then no fields will be returned at all. You could pass an "x", for example:
?fields=x
But please keep in mind that this is an undocumented "feature" and therefore not guaranteed to work forever. Best practice would be to include the summary field as you mentioned, and then simply ignore this field in your code, as the overhead of one field is negligible.
I never realized that, cool. I only ever managed to get the set of fields down to the required system fields of summary, issue type and reporter. And status I guess
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Also, you could force the endpoint to return only the ID field by declaring only it:
?fields=id
...but you still get back other, non-excludable response objects such as expand, self and key,
If you want to be sneaky and get just the issueId value and no other objects in the response, use the Search Issue IDs using JQL endpoint and search for just one issue key:
POST:
{{Instance}}/rest/api/3/search/id
Body:
{
"jql": "key = ABC-123"
}
Response:
{
"issueIds": [
10001
]
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.