Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
0 / 0 points
badges earned

Your Points Tracker
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How can I fetch the value of a label of an issue via a curl command with jql written in the url? Edited

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.

1 answer

1 accepted

2 votes
Answer accepted
Payne Community Leader May 27, 2021

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. the the issue ID to your issue of interest):

Sample response:

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

Like Payne likes this

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.

Like Ryan Kaviani likes this

Suggest an answer

Log in or Sign up to answer

Community Events

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

Events near you