Jira REST API JQL only get "Bug"

I’m trying to create a method that retrieves specific issuetypes, and have created code as:

        var httpClient = new HttpClient();
        var request = new HttpRequestMessage(new HttpMethod("GET"), "https://mydomainurl/rest/api/2/search?jql=project=ATLS1&issuetypeNames=Bug");
        request.Headers.TryAddWithoutValidation("Accept", "application/json");
        var base64authorization = Convert.ToBase64String(Encoding.ASCII.GetBytes($"myemail@address.com:{APIToken}"));

        request.Headers.TryAddWithoutValidation("Authorization", $"Basic {base64authorization}");
        var response = await httpClient.SendAsync(request);
        var jsonString = await response.Content.ReadAsStringAsync();

As I’m new to Jira, is there a way in the jql string to only select by Bug, User Story, etc.? (i.e. I only want to retrieve Bugs)

I’m currently using the search query and it is returning everything.

@zfischer,

Your query is close. Substitute issuetype for issuetypeNames and it should work. I find querying in the UI is the fastest “dev loop” for JQL. What do you know?!? A brand new demo of the new JQL editor:

Thanks Ian.

I have tried the substitution as follows:

var request = new HttpRequestMessage(new HttpMethod(“GET”), “https://mydomain/rest/api/2/issue?jql=project=ATLS1&issuetype=Bug”);

The problem I see is that Jira is returning ALL issues rather than just the bug. In my test project I have 1 issue, 1 bug, and one user story. I would expect to only see the one bug, but the JSON response includes all of them

@zfischer,

In the first example, you were using GET /rest/api/2/search, which should work with correct JQL, and in this latest example, you have switched to GET /rest/api/2/issue, which should return 405 with GET.

Assuming you are still using the search endpoint, I think I see the problem now. I didn’t realize that JQL would let you use & for the AND operator (today I learned). In the Jira UI, that’s fine but in a URL parameter & is a parameter separator; hence, it is not part of your JQL. Switch & to AND.