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 to create a jql query for Bugs only within a project

I am trying to put together some queries to use in my app making JIRA api calls to get the data.  The big thing is to try and get jiras where issuetype = Bug, given a specific project.  I would like to use the POST method as going forward the queries may get more complicated. What I have so far is:

string postData = "{\"jql\":\"project = Myproject\", \"fields\": {\"issuetype\":{\"name\":\"Bug\"}}}";
byte[] byteArray = Encoding.UTF8.GetBytes(postData);

string encodedCreds = Base64Encode("username:password"); //this needs to be changed to Qed Arsenal access info once that gets setup
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("company specific url");
request.Method = "POST";
request.ContentType = "application/json";
request.Headers.Add("Authorization", "Basic " + encodedCreds);

request.ContentLength = byteArray.Length;
Stream dataStream = request.GetRequestStream();
dataStream.Write(byteArray, 0, byteArray.Length);

HttpWebResponse webResponse = (HttpWebResponse)request.GetResponse();
dataStream = webResponse.GetResponseStream();
StreamReader responseReader = new StreamReader(dataStream);
string res = responseReader.ReadToEnd();

return res;

3 answers

1 accepted

1 vote
Answer accepted

Did you try GET instead of POST with your JQL encoded in URL string ?

Atlassian REST API DOC doc says you should use POST only when your QSL is too long to be encoded

GET vs POST: If the JQL query is too large to be encoded as a query param you should instead POST to this resource. Example: /rest/api/2/search?jql

This is a simple example the project I am using will return over 4,000 issues (searching on project alone).  I am trying to find ways to trim it down.  First all I care about are the bugs, second I would like to have dynamic ability to do other complex searching that could help further whittle the returns down.  Also, it would be nice to only get certain sections of the jiras to be returned like the issueType, and status, etc.. I would like to avoid getting entire issue on large searches as the app I am working on is only concerned with status of bugs and maybe created dates.  I also wanted to do it this way (POST) so I have one solution for all my queries complex or not.

Besides I am not sure how to setup the query for a GET to just return issues of type bug either (Key and Id are unknowns).

Please read the doc

You can do either GET or POST and you can limit fields and number of results in either one of them with additional query parameters in URL:


unfortunately I cannot open that file.  I have been doing some more digging and I know how to limit the response to only the fields I want, but still have not figured out how to create a query for bugs only when I do not know the ID or Key. Also, would be nice to be able to limit search results based on when created (i.e. date range).

Sorry my bad. I pasted wrong link in my previous comment. I corrected the link now.

JQL example to search for bugs only limited to issues created in year 2015 in project PLAY will look like this one: project = PLAY and issuetype = Bug and created > "2015/01/01" and created < "2015/12/31"

Yes you can search for specific keyword in the summary. Modifying my previous example JQL would look like: 

project = PLAY and issuetype = Bug and created > "2015/01/01" and created < "2015/12/31" and summary ~ "PRWLN%"

Also your last comment query string example is not right. The whole JQL string is the value for one parameter named jql, not a separate parameters for issuetype, created etc. So your corrected example would look like:

/rest/api/latest/search/?jql=project=MyProject and issuetype=Bug and created >"2016/03/01" and created < "2016/03/11" &fields=summary,status,created,updated,assignee,issuetype

Blanks will be replaced with %20 after URL string is encoded 


Looks like you accepted your own comment which was made in format of answer. Were you really going to accept my answer in this thread ?

yes I wanted to accept your answer.  Obviously I had no answer for myself just a lot of questions. I will just accept the one below.

Thank you for the link it is proving very helpful.  Also thanks for the date range sample. I will definitely be playing around with it and tweaking to my needs. One last final question.  The project that I am dealing with has many teams with own products all under same project name (I know not very helpful).  However, for my particular project we prefix each JIRA name (summary field) with an acronym.  Is there a way to only get results where summary contains said acronym.

for example: "PRWLN this bug is really bad"

right now my query is starting to shape up I think this would be final piece.

what I have so far:

/rest/api/latest/search/?jql=project=MyProject&issuetype=Bug&created >"2016/03/01" and created < "2016/03/11" &fields=summary,status,created,updated,assignee,issuetype

/search?jql=project = APPT&issuetype=Bug&created >"2017/01/01" and created < "2017/04/01"&maxResults=100&fields=summary,duedate,issuetype,priority,customfield_11783,status,customfield_17941,customfield_11771

It is not giving only the Bugs with in the date range >"2017/01/01" and created < "2017/04/01" and  &issuetype=Bug .


I am getting 100 records for /search?jql=project = APPT , no change with issuetype and created filter 

Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Jira

Managing Incidents - The roof is on FIRE!

The roof is on FIRE… network outages, broken processes, upset clients and employees. Each day seemed to bring more and more issues. Incidents were communicated via email, messengers (skype or teams) ...

135 views 0 1
Read article

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