Sample code for 30+ languages & platforms
Xojo Plugin Requires Chilkat v11.0.0+

Jira Cloud: List Boards, Sprints, and Sprint Issues

See more Jira Examples

Find a board within a project by name, find a sprint on that board, and list its issues. Each list is paginated. Duplicate board or sprint names are treated as ambiguous; choose an ID explicitly if names are not unique.

Boards and sprints belong to the Jira Software REST API. A board's filter and the user's permissions affect what is visible. Sprints must be enabled for the selected board. Team-managed boards can have type simple even when sprints are enabled, so the discovery request does not restrict results to type=scrum. The final request uses the enhanced sprint-issue endpoint with token pagination, rather than the deprecated offset-based issue endpoint. OAuth integrations need the Jira Software scopes listed by these endpoints in addition to platform scopes.

The code uses an Atlassian account email and an API token without scopes with the site URL. For a scoped API token, keep Basic authentication and change baseUrl to https://api.atlassian.com/ex/jira/YOUR_CLOUD_ID. For OAuth2, use that gateway URL, omit Login/Password/BasicAuth, and set http.AuthToken to the access token. See API token authentication and OAuth2 authorization. The account must have permission for the operation; OAuth scopes do not grant additional Jira permissions.

Targets Jira Cloud. Jira Data Center has a separate REST API and may require different paths, authentication, or payloads.

Atlassian REST API documentation

Chilkat Xojo Plugin Downloads

Xojo Plugin
Dim success As Boolean
success = False

//  Assumes Chilkat is unlocked. See Global Unlock Sample.

Dim http As New Chilkat.Http
http.RequireSslCertVerify = True
http.BasicAuth = True
//  Read these credentials from private application configuration.
http.Login = "YOUR_ATLASSIAN_EMAIL"
http.Password = "YOUR_API_TOKEN"
Dim baseUrl As String
baseUrl = "https://your-domain.atlassian.net"
http.Accept = "application/json"
Dim url As New Chilkat.StringBuilder
Dim resp As New Chilkat.HttpResponse
Dim reply As New Chilkat.JsonObject
Dim boardName As String
boardName = "Example Board"
Dim sprintName As String
sprintName = "Sprint 1"
Dim boardId As String
boardId = ""
Dim sprintId As String
sprintId = ""
Dim boardMatches As Int32
boardMatches = 0
Dim sprintMatches As Int32
sprintMatches = 0
success = http.SetUrlVar("projectKey","PROJECT")
success = http.SetUrlVar("boardName",boardName)
//  Team-managed boards can have type simple, including boards with sprints enabled.
Dim boardsStart As Int32
boardsStart = 0
Dim boardsMore As Boolean
boardsMore = True
Dim boardsOffset As New Chilkat.StringBuilder
While (boardsMore = True)
    boardsOffset.Clear 
    success = boardsOffset.AppendInt(boardsStart)
    success = http.SetUrlVar("offset",boardsOffset.GetAsString())
    success = url.SetString(baseUrl)
    success = url.Append("/rest/agile/1.0/board?projectKeyOrId={$projectKey}&name={$boardName}&startAt={$offset}&maxResults=50")
    success = http.HttpNoBody("GET",url.GetAsString(),resp)
    If (resp.StatusCode = 0) Then
        System.DebugLog("No HTTP response was received. Check connectivity and TLS settings.")
        Return
    End If

    If ((success <> True) Or (resp.StatusCode < 200) Or (resp.StatusCode >= 300)) Then
        System.DebugLog("Request failed. HTTP " + Str(resp.StatusCode))
        If (resp.StatusCode = 429) Then
            System.DebugLog("Rate limited. Retry-After: " + resp.GetHeaderField("Retry-After"))
        End If

        //  Inspect this response locally; it can contain private Jira data.
        System.DebugLog(resp.BodyStr)
        Return
    End If

    success = reply.Load(resp.BodyStr)
    If (success <> True) Then
        System.DebugLog("Expected a JSON object in the response.")
        Return
    End If

    If (reply.JsonTypeOf("values") <> 4) Then
        System.DebugLog("Expected an array: values")
        Return
    End If

    Dim boardsCount As Int32
    boardsCount = reply.SizeOfArray("values")
    Dim boardsIndex As Int32
    boardsIndex = 0
    While (boardsIndex < boardsCount)
        reply.I = boardsIndex
        System.DebugLog("Board: " + reply.StringOf("values[i].name") + "  ID: " + reply.StringOf("values[i].id"))
        If (reply.StringOfEquals("values[i].name",boardName,True) = True) Then
            boardId = reply.StringOf("values[i].id")
            boardMatches = boardMatches + 1
        End If

        boardsIndex = boardsIndex + 1
    Wend
    boardsStart = boardsStart + boardsCount
    boardsMore = (reply.BoolOf("isLast") <> True)
    If ((boardsMore = True) And (boardsCount = 0)) Then
        System.DebugLog("Pagination made no progress; stopping.")
        Return
    End If

Wend
If (boardMatches <> 1) Then
    System.DebugLog("Expected exactly one matching board in this project.")
    Return
End If

success = http.SetUrlVar("boardId",boardId)
Dim sprintsStart As Int32
sprintsStart = 0
Dim sprintsMore As Boolean
sprintsMore = True
Dim sprintsOffset As New Chilkat.StringBuilder
While (sprintsMore = True)
    sprintsOffset.Clear 
    success = sprintsOffset.AppendInt(sprintsStart)
    success = http.SetUrlVar("offset",sprintsOffset.GetAsString())
    success = url.SetString(baseUrl)
    success = url.Append("/rest/agile/1.0/board/{$boardId}/sprint?startAt={$offset}&maxResults=50")
    success = http.HttpNoBody("GET",url.GetAsString(),resp)
    If (resp.StatusCode = 0) Then
        System.DebugLog("No HTTP response was received. Check connectivity and TLS settings.")
        Return
    End If

    If ((success <> True) Or (resp.StatusCode < 200) Or (resp.StatusCode >= 300)) Then
        System.DebugLog("Request failed. HTTP " + Str(resp.StatusCode))
        If (resp.StatusCode = 429) Then
            System.DebugLog("Rate limited. Retry-After: " + resp.GetHeaderField("Retry-After"))
        End If

        //  Inspect this response locally; it can contain private Jira data.
        System.DebugLog(resp.BodyStr)
        Return
    End If

    success = reply.Load(resp.BodyStr)
    If (success <> True) Then
        System.DebugLog("Expected a JSON object in the response.")
        Return
    End If

    If (reply.JsonTypeOf("values") <> 4) Then
        System.DebugLog("Expected an array: values")
        Return
    End If

    Dim sprintsCount As Int32
    sprintsCount = reply.SizeOfArray("values")
    Dim sprintsIndex As Int32
    sprintsIndex = 0
    While (sprintsIndex < sprintsCount)
        reply.I = sprintsIndex
        System.DebugLog("Sprint: " + reply.StringOf("values[i].name") + "  " + reply.StringOf("values[i].state") + "  ID: " + reply.StringOf("values[i].id"))
        If (reply.StringOfEquals("values[i].name",sprintName,True) = True) Then
            sprintId = reply.StringOf("values[i].id")
            sprintMatches = sprintMatches + 1
        End If

        sprintsIndex = sprintsIndex + 1
    Wend
    sprintsStart = sprintsStart + sprintsCount
    sprintsMore = (reply.BoolOf("isLast") <> True)
    If ((sprintsMore = True) And (sprintsCount = 0)) Then
        System.DebugLog("Pagination made no progress; stopping.")
        Return
    End If

Wend
If (sprintMatches <> 1) Then
    System.DebugLog("Expected exactly one matching sprint.")
    Return
End If

success = http.SetUrlVar("sprintId",sprintId)
Dim nextToken As String
nextToken = ""
Dim previousToken As String
previousToken = ""
Dim more As Boolean
more = True
While (more = True)
    success = http.SetUrlVar("nextToken",nextToken)
    success = url.SetString(baseUrl)
    success = url.Append("/rest/software/1.0/sprint/{$sprintId}/issue?maxResults=50&fields=summary,status")
    If (nextToken <> "") Then
        success = url.Append("&nextPageToken={$nextToken}")
    End If

    success = http.HttpNoBody("GET",url.GetAsString(),resp)
    If (resp.StatusCode = 0) Then
        System.DebugLog("No HTTP response was received. Check connectivity and TLS settings.")
        Return
    End If

    If ((success <> True) Or (resp.StatusCode < 200) Or (resp.StatusCode >= 300)) Then
        System.DebugLog("Request failed. HTTP " + Str(resp.StatusCode))
        If (resp.StatusCode = 429) Then
            System.DebugLog("Rate limited. Retry-After: " + resp.GetHeaderField("Retry-After"))
        End If

        //  Inspect this response locally; it can contain private Jira data.
        System.DebugLog(resp.BodyStr)
        Return
    End If

    success = reply.Load(resp.BodyStr)
    If (success <> True) Then
        System.DebugLog("Expected a JSON object in the response.")
        Return
    End If

    If (reply.JsonTypeOf("issues") <> 4) Then
        System.DebugLog("Expected an array: issues")
        Return
    End If

    Dim i As Int32
    i = 0
    While (i < reply.SizeOfArray("issues"))
        reply.I = i
        System.DebugLog(reply.StringOf("issues[i].key") + "  " + reply.StringOf("issues[i].fields.summary"))
        i = i + 1
    Wend
    more = (reply.BoolOf("isLast") <> True)
    If (more = True) Then
        If ((reply.JsonTypeOf("nextPageToken") <> 1) Or (reply.StringOfEquals("nextPageToken","",True) = True)) Then
            System.DebugLog("Missing value: nextPageToken")
            Return
        End If

        nextToken = reply.StringOf("nextPageToken")
        If (nextToken = previousToken) Then
            System.DebugLog("Repeated pagination token; stopping.")
            Return
        End If

        previousToken = nextToken
    End If

Wend