Sample code for 30+ languages & platforms
AutoIt 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 AutoIt Downloads

AutoIt
Local $bSuccess = False

;  Assumes Chilkat is unlocked. See Global Unlock Sample.

$oHttp = ObjCreate("Chilkat.Http")
$oHttp.RequireSslCertVerify = True
$oHttp.BasicAuth = True
;  Read these credentials from private application configuration.
$oHttp.Login = "YOUR_ATLASSIAN_EMAIL"
$oHttp.Password = "YOUR_API_TOKEN"
Local $sBaseUrl = "https://your-domain.atlassian.net"
$oHttp.Accept = "application/json"
$oUrl = ObjCreate("Chilkat.StringBuilder")
$oResp = ObjCreate("Chilkat.HttpResponse")
$oReply = ObjCreate("Chilkat.JsonObject")
Local $sBoardName = "Example Board"
Local $sprintName = "Sprint 1"
Local $sBoardId = ""
Local $sprintId = ""
Local $iBoardMatches = 0
Local $iSprintMatches = 0
$oHttp.SetUrlVar("projectKey","PROJECT")
$oHttp.SetUrlVar("boardName",$sBoardName)
;  Team-managed boards can have type simple, including boards with sprints enabled.
Local $iBoardsStart = 0
Local $boardsMore = True
$oBoardsOffset = ObjCreate("Chilkat.StringBuilder")
While ($boardsMore = True)
    $oBoardsOffset.Clear 
    $oBoardsOffset.AppendInt($iBoardsStart)
    $oHttp.SetUrlVar("offset",$oBoardsOffset.GetAsString())
    $oUrl.SetString($sBaseUrl)
    $oUrl.Append("/rest/agile/1.0/board?projectKeyOrId={$projectKey}&name={$boardName}&startAt={$offset}&maxResults=50")
    $bSuccess = $oHttp.HttpNoBody("GET",$oUrl.GetAsString(),$oResp)
    If ($oResp.StatusCode = 0) Then
        ConsoleWrite("No HTTP response was received. Check connectivity and TLS settings." & @CRLF)
        Exit
    EndIf

    If (($bSuccess <> True) Or ($oResp.StatusCode < 200) Or ($oResp.StatusCode >= 300)) Then
        ConsoleWrite("Request failed. HTTP " & $oResp.StatusCode & @CRLF)
        If ($oResp.StatusCode = 429) Then
            ConsoleWrite("Rate limited. Retry-After: " & $oResp.GetHeaderField("Retry-After") & @CRLF)
        EndIf

        ;  Inspect this response locally; it can contain private Jira data.
        ConsoleWrite($oResp.BodyStr & @CRLF)
        Exit
    EndIf

    $bSuccess = $oReply.Load($oResp.BodyStr)
    If ($bSuccess <> True) Then
        ConsoleWrite("Expected a JSON object in the response." & @CRLF)
        Exit
    EndIf

    If ($oReply.JsonTypeOf("values") <> 4) Then
        ConsoleWrite("Expected an array: values" & @CRLF)
        Exit
    EndIf

Local $iBoardsCount = $oReply.SizeOfArray("values")
Local $iBoardsIndex = 0
    While ($iBoardsIndex < $iBoardsCount)
        $oReply.I = $iBoardsIndex
        ConsoleWrite("Board: " & $oReply.StringOf("values[i].name") & "  ID: " & $oReply.StringOf("values[i].id") & @CRLF)
        If ($oReply.StringOfEquals("values[i].name",$sBoardName,True) = True) Then
            $sBoardId = $oReply.StringOf("values[i].id")
            $iBoardMatches = $iBoardMatches + 1
        EndIf

        $iBoardsIndex = $iBoardsIndex + 1
    Wend
    $iBoardsStart = $iBoardsStart + $iBoardsCount
    $boardsMore = ($oReply.BoolOf("isLast") <> True)
    If (($boardsMore = True) And ($iBoardsCount = 0)) Then
        ConsoleWrite("Pagination made no progress; stopping." & @CRLF)
        Exit
    EndIf

Wend
If ($iBoardMatches <> 1) Then
    ConsoleWrite("Expected exactly one matching board in this project." & @CRLF)
    Exit
EndIf

$oHttp.SetUrlVar("boardId",$sBoardId)
Local $iSprintsStart = 0
Local $bSprintsMore = True
$oSprintsOffset = ObjCreate("Chilkat.StringBuilder")
While ($bSprintsMore = True)
    $oSprintsOffset.Clear 
    $oSprintsOffset.AppendInt($iSprintsStart)
    $oHttp.SetUrlVar("offset",$oSprintsOffset.GetAsString())
    $oUrl.SetString($sBaseUrl)
    $oUrl.Append("/rest/agile/1.0/board/{$boardId}/sprint?startAt={$offset}&maxResults=50")
    $bSuccess = $oHttp.HttpNoBody("GET",$oUrl.GetAsString(),$oResp)
    If ($oResp.StatusCode = 0) Then
        ConsoleWrite("No HTTP response was received. Check connectivity and TLS settings." & @CRLF)
        Exit
    EndIf

    If (($bSuccess <> True) Or ($oResp.StatusCode < 200) Or ($oResp.StatusCode >= 300)) Then
        ConsoleWrite("Request failed. HTTP " & $oResp.StatusCode & @CRLF)
        If ($oResp.StatusCode = 429) Then
            ConsoleWrite("Rate limited. Retry-After: " & $oResp.GetHeaderField("Retry-After") & @CRLF)
        EndIf

        ;  Inspect this response locally; it can contain private Jira data.
        ConsoleWrite($oResp.BodyStr & @CRLF)
        Exit
    EndIf

    $bSuccess = $oReply.Load($oResp.BodyStr)
    If ($bSuccess <> True) Then
        ConsoleWrite("Expected a JSON object in the response." & @CRLF)
        Exit
    EndIf

    If ($oReply.JsonTypeOf("values") <> 4) Then
        ConsoleWrite("Expected an array: values" & @CRLF)
        Exit
    EndIf

Local $iSprintsCount = $oReply.SizeOfArray("values")
Local $iSprintsIndex = 0
    While ($iSprintsIndex < $iSprintsCount)
        $oReply.I = $iSprintsIndex
        ConsoleWrite("Sprint: " & $oReply.StringOf("values[i].name") & "  " & $oReply.StringOf("values[i].state") & "  ID: " & $oReply.StringOf("values[i].id") & @CRLF)
        If ($oReply.StringOfEquals("values[i].name",$sprintName,True) = True) Then
            $sprintId = $oReply.StringOf("values[i].id")
            $iSprintMatches = $iSprintMatches + 1
        EndIf

        $iSprintsIndex = $iSprintsIndex + 1
    Wend
    $iSprintsStart = $iSprintsStart + $iSprintsCount
    $bSprintsMore = ($oReply.BoolOf("isLast") <> True)
    If (($bSprintsMore = True) And ($iSprintsCount = 0)) Then
        ConsoleWrite("Pagination made no progress; stopping." & @CRLF)
        Exit
    EndIf

Wend
If ($iSprintMatches <> 1) Then
    ConsoleWrite("Expected exactly one matching sprint." & @CRLF)
    Exit
EndIf

$oHttp.SetUrlVar("sprintId",$sprintId)
Local $sNextToken = ""
Local $sPreviousToken = ""
Local $bMore = True
While ($bMore = True)
    $oHttp.SetUrlVar("nextToken",$sNextToken)
    $oUrl.SetString($sBaseUrl)
    $oUrl.Append("/rest/software/1.0/sprint/{$sprintId}/issue?maxResults=50&fields=summary,status")
    If ($sNextToken <> "") Then
        $oUrl.Append("&nextPageToken={$nextToken}")
    EndIf

    $bSuccess = $oHttp.HttpNoBody("GET",$oUrl.GetAsString(),$oResp)
    If ($oResp.StatusCode = 0) Then
        ConsoleWrite("No HTTP response was received. Check connectivity and TLS settings." & @CRLF)
        Exit
    EndIf

    If (($bSuccess <> True) Or ($oResp.StatusCode < 200) Or ($oResp.StatusCode >= 300)) Then
        ConsoleWrite("Request failed. HTTP " & $oResp.StatusCode & @CRLF)
        If ($oResp.StatusCode = 429) Then
            ConsoleWrite("Rate limited. Retry-After: " & $oResp.GetHeaderField("Retry-After") & @CRLF)
        EndIf

        ;  Inspect this response locally; it can contain private Jira data.
        ConsoleWrite($oResp.BodyStr & @CRLF)
        Exit
    EndIf

    $bSuccess = $oReply.Load($oResp.BodyStr)
    If ($bSuccess <> True) Then
        ConsoleWrite("Expected a JSON object in the response." & @CRLF)
        Exit
    EndIf

    If ($oReply.JsonTypeOf("issues") <> 4) Then
        ConsoleWrite("Expected an array: issues" & @CRLF)
        Exit
    EndIf

Local $i = 0
    While ($i < $oReply.SizeOfArray("issues"))
        $oReply.I = $i
        ConsoleWrite($oReply.StringOf("issues[i].key") & "  " & $oReply.StringOf("issues[i].fields.summary") & @CRLF)
        $i = $i + 1
    Wend
    $bMore = ($oReply.BoolOf("isLast") <> True)
    If ($bMore = True) Then
        If (($oReply.JsonTypeOf("nextPageToken") <> 1) Or ($oReply.StringOfEquals("nextPageToken","",True) = True)) Then
            ConsoleWrite("Missing value: nextPageToken" & @CRLF)
            Exit
        EndIf

        $sNextToken = $oReply.StringOf("nextPageToken")
        If ($sNextToken = $sPreviousToken) Then
            ConsoleWrite("Repeated pagination token; stopping." & @CRLF)
            Exit
        EndIf

        $sPreviousToken = $sNextToken
    EndIf

Wend