I am a complete beginner in terms of knowledge of JIRA and JQL, so I apologize if I ask 'the same thing' twice. Please do your best to explain things at a beginner level.
I understand curl on linux transfers server data, and in my case it just prints onto a terminal. I want to be able to run a curl command on a JIRA issue page, and have it print out a specific value--the value of the labels.
I have read that JQL does not support this since JQL cannot return field values specifically, but I wanted to ask this question myself to see if there was an update. Can I use JQL to return a field value ONLY? That way when I run my curl command I print that value ONLY?
Thank you ahead of time, I do not expect a 'yes,' I would just like to know if I am wasting my time looking for an answer.
You can utilize the API to send a JQL query and specify the the field(s) you would like returned. The response will contain a bit more than just the label values, but not much more.
Sample URL you can call from curl (change YOURDOMAIN to your Jira app's domain, e.g. jira.mycompany.com the the issue ID to your issue of interest):
I see now, I was hitting the wrong endpoint. I've built a command now that is:
curl --request GET --url 'https://<MYDOMAIN>/rest/api/2/field' --header 'Accept: application/json'
and it just returns everything (still a step in the right direction). Now at this point I turn to your URL sample.
At this point I understood your code, so I tried it, but for some reason when I tried the command you referenced, I was getting a total of 0 hits. I know for a fact that I have the right ID, because I manually used it in the search bar and it returned the right issue, but it won't print anything on the terminal. I just get this back:
Is there something I am missing? This is the command that is returning no hits, despite there really being one:
curl --request GET --url 'https://<MYDOMAIN>/rest/api/2/search?jql=id=XXXXXXX-000' --header 'Accept: application/json'
You're likely not authenticated; try the following. Note also that I have to use double quotes rather than single quotes with curl.
curl --user USERNAME --request GET --url "https://YOURDOMAIN/rest/api/2/search?jql=id=BR-12411&fields=labels"
curl --user USERNAME:PASSWORD --request GET --url "https://YOURDOMAIN/rest/api/2/search?jql=id=BR-12411&fields=labels"
Thanks for the help! I finally got what you did! I have a couple more questions if you could still help:
1) The place where you input a password is called the api_token according to the REST API, is this the same as an OAuth token that you can generate? I tried using one I just made but it wouldn't authenticate me. If not, how can I generate one so that I wouldn't need to enter my password in the code or enter it every time I call this command?
2) Say I wanted to search by project name instead ,but I have a space in a project title (i.e.- "Example Title"). How would I write this?
I'm trying to do: .../search?jql=project="Example Title"&fields=labels
1. Hmm, that's beyond my level of experience and understanding. Perhaps someone else can chime in with some guidance on that.
2. Use %20 in place of spaces, and wrap the project name in single quotes, e.g.
curl --user USERNAME --request GET --url "https://YOURDOMAIN/rest/api/2/search?jql=id=BR-12411%20and%20project='Business%20Operational%20Requests'&fields=labels"
or, you can also use the project key (BR in my case) rather than the name.
Connect with like-minded Atlassian users at free events near you!Find an event
Connect with like-minded Atlassian users at free events near you!
Unfortunately there are no Community Events near you at the moment.Host an event
You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events