Reputation: 151
Good Day All, I'm having some issues forming the right JQL syntax for a Jira curl request. Here is what I currently have, and this is working.
curl -D- -u jenkins:password123 -X POST -d "{\"jql\": \"issuetype = 'Broker AutoDeploy' AND status = 'In Progress'\",\"fields\":[\"key\"]}" -H "Content-Type: application/json" http://jira.site.com:8080/rest/api/2/search
This curl will return the correct issue, but will only give me the "key" of those issues. I've tried adding onto the end of my jql, something like this below.
"{\"jql\": \"issuetype = 'Broker AutoDeploy' AND status = 'In Progress'\",\"fields\":[\"key\"],[\"status\"]}"
But I get errors, as I'm not certain of how to form my syntax. Does anyone know the proper syntax to do something like this?
Thank you for any insight!
Upvotes: 1
Views: 1107
Reputation: 151
Thank you Adil B, Your answer was really close and It got me to the correct syntax. Here is what worked for me.
{\"jql\": \"issuetype = 'Broker AutoDeploy' AND status = 'In Progress'\",\"fields\":[\"issuetype\",\"status\"]}
I needed to separate each field being requested with its own set of quotation marks, also since key is the primary key, I didn't have to specifically request for it.
Upvotes: 1
Reputation: 16866
Looking at the example from Atlassian's REST API documentation pages, you should be specifying the fields you'd like to include as a comma-separated list: key,status
in your case.
Your updated JQL parameter should look like this:
"{\"jql\": \"issuetype = 'Broker AutoDeploy' AND status = 'In Progress'\",\"fields\":\"key,status\"}"
Upvotes: 1