Fetch a list of all 'open' issues

Hi. I have just started digging into this API to do what I thought would be a very simple task. I just want to write a console app in vb.net to retrieve a list of issues from JIRA cloud which we can use locally for our own reporting. I was hoping there would be some sample code or a tutorial on how to do this, but all I can find is information on extending JIRA functionality etc which is way beyond what I want to do.

Is there somewhere a simple sample app that does this? Even if it’s in a different language, just so that I can get the gist of what needs to be done to achieve this without having to spend hours trying to get my head around the API.

Here’s a quick and dirty step-by-step:

Just making sample API call from your browser

  1. Login to your Jira Cloud account
  2. Point your browser to https://yourinstancename.atlassian.net/rest/api/2/search?jql=resolution+is+empty
    Replace yourinstancename in the URL with your actual Jira Cloud instance name. All we’re doing is sending a JQL query with the REST API. This works (authorization wise), because the API is accepting the authorized session cookies by being logged in from step 1.

Doing it programmatically with Basic Auth

  1. Login to your Jira account
  2. Point your browser to https://id.atlassian.com/manage/api-tokens
  3. Click the button labeled Create API Token
  4. Give it any arbitrary name (just for your own reference)
  5. Copy that API token and paste it into a safe place (and save it) – you won’t be shown this anywhere else again
  6. Calculate your basic auth token by Base64 encoding the following string: foo@bar.com:API_TOKEN – that email address is your login name, followed by a colon, and and API_TOKEN is from last step. You can use online tools to generate the Base64 like this one.
  7. In your native language, make an HTTP GET call to: https://yourinstancename.atlassian.net/rest/api/2/search?jql=resolution%20is%20empty` with the following HTTP headers:
    • Authorization: Basic BASE64_ENCODED_BASIC_TOKEN
    • Accept: application/json

If you want to fetch a single issue, use the Get Issue method (link is to docs).

1 Like

Quick and dirty is exactly what I needed! Thanks for the quick response :slight_smile:

Never mind, I got it to work using basic authentication:

Dim sCredentials As String = Convert.ToBase64String(ASCIIEncoding.ASCII.GetBytes(myemail + “:” + sAPIToken))
req.Headers.Add(“Authorization”, "Basic " + sCredentials)

Instead of:

req.Headers.Add(“Authorization”, "Bearer " + sAPIToken)

Good gracious… my mistake. I was in Stride API mode (which uses OAuth 2). I’ve updated my original response. #doh

p.s. I’m hiding your two other responses so that they don’t get indexed by GOOG, and/or confuse the turbo-copy-pasters of the future that will need help.

1 Like