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 Delphi DLL Downloads
var
success: Boolean;
http: HCkHttp;
baseUrl: PWideChar;
url: HCkStringBuilder;
resp: HCkHttpResponse;
reply: HCkJsonObject;
boardName: PWideChar;
sprintName: PWideChar;
boardId: PWideChar;
sprintId: PWideChar;
boardMatches: Integer;
sprintMatches: Integer;
boardsStart: Integer;
boardsMore: Boolean;
boardsOffset: HCkStringBuilder;
boardsCount: Integer;
boardsIndex: Integer;
sprintsStart: Integer;
sprintsMore: Boolean;
sprintsOffset: HCkStringBuilder;
sprintsCount: Integer;
sprintsIndex: Integer;
nextToken: PWideChar;
previousToken: PWideChar;
more: Boolean;
i: Integer;
begin
success := False;
// Assumes Chilkat is unlocked. See Global Unlock Sample.
http := CkHttp_Create();
CkHttp_putRequireSslCertVerify(http,True);
CkHttp_putBasicAuth(http,True);
// Read these credentials from private application configuration.
CkHttp_putLogin(http,'YOUR_ATLASSIAN_EMAIL');
CkHttp_putPassword(http,'YOUR_API_TOKEN');
baseUrl := 'https://your-domain.atlassian.net';
CkHttp_putAccept(http,'application/json');
url := CkStringBuilder_Create();
resp := CkHttpResponse_Create();
reply := CkJsonObject_Create();
boardName := 'Example Board';
sprintName := 'Sprint 1';
boardId := '';
sprintId := '';
boardMatches := 0;
sprintMatches := 0;
CkHttp_SetUrlVar(http,'projectKey','PROJECT');
CkHttp_SetUrlVar(http,'boardName',boardName);
// Team-managed boards can have type simple, including boards with sprints enabled.
boardsStart := 0;
boardsMore := True;
boardsOffset := CkStringBuilder_Create();
while (boardsMore = True) do
begin
CkStringBuilder_Clear(boardsOffset);
CkStringBuilder_AppendInt(boardsOffset,boardsStart);
CkHttp_SetUrlVar(http,'offset',CkStringBuilder__getAsString(boardsOffset));
CkStringBuilder_SetString(url,baseUrl);
CkStringBuilder_Append(url,'/rest/agile/1.0/board?projectKeyOrId={$projectKey}&name={$boardName}&startAt={$offset}&maxResults=50');
success := CkHttp_HttpNoBody(http,'GET',CkStringBuilder__getAsString(url),resp);
if (CkHttpResponse_getStatusCode(resp) = 0) then
begin
Memo1.Lines.Add('No HTTP response was received. Check connectivity and TLS settings.');
Exit;
end;
if ((success <> True) or (CkHttpResponse_getStatusCode(resp) < 200) or (CkHttpResponse_getStatusCode(resp) >= 300)) then
begin
Memo1.Lines.Add('Request failed. HTTP ' + IntToStr(CkHttpResponse_getStatusCode(resp)));
if (CkHttpResponse_getStatusCode(resp) = 429) then
begin
Memo1.Lines.Add('Rate limited. Retry-After: ' + CkHttpResponse__getHeaderField(resp,'Retry-After'));
end;
// Inspect this response locally; it can contain private Jira data.
Memo1.Lines.Add(CkHttpResponse__bodyStr(resp));
Exit;
end;
success := CkJsonObject_Load(reply,CkHttpResponse__bodyStr(resp));
if (success <> True) then
begin
Memo1.Lines.Add('Expected a JSON object in the response.');
Exit;
end;
if (CkJsonObject_JsonTypeOf(reply,'values') <> 4) then
begin
Memo1.Lines.Add('Expected an array: values');
Exit;
end;
boardsCount := CkJsonObject_SizeOfArray(reply,'values');
boardsIndex := 0;
while (boardsIndex < boardsCount) do
begin
CkJsonObject_putI(reply,boardsIndex);
Memo1.Lines.Add('Board: ' + CkJsonObject__stringOf(reply,'values[i].name') + ' ID: ' + CkJsonObject__stringOf(reply,'values[i].id'));
if (CkJsonObject_StringOfEquals(reply,'values[i].name',boardName,True) = True) then
begin
boardId := CkJsonObject__stringOf(reply,'values[i].id');
boardMatches := boardMatches + 1;
end;
boardsIndex := boardsIndex + 1;
end;
boardsStart := boardsStart + boardsCount;
boardsMore := (CkJsonObject_BoolOf(reply,'isLast') <> True);
if ((boardsMore = True) and (boardsCount = 0)) then
begin
Memo1.Lines.Add('Pagination made no progress; stopping.');
Exit;
end;
end;
if (boardMatches <> 1) then
begin
Memo1.Lines.Add('Expected exactly one matching board in this project.');
Exit;
end;
CkHttp_SetUrlVar(http,'boardId',boardId);
sprintsStart := 0;
sprintsMore := True;
sprintsOffset := CkStringBuilder_Create();
while (sprintsMore = True) do
begin
CkStringBuilder_Clear(sprintsOffset);
CkStringBuilder_AppendInt(sprintsOffset,sprintsStart);
CkHttp_SetUrlVar(http,'offset',CkStringBuilder__getAsString(sprintsOffset));
CkStringBuilder_SetString(url,baseUrl);
CkStringBuilder_Append(url,'/rest/agile/1.0/board/{$boardId}/sprint?startAt={$offset}&maxResults=50');
success := CkHttp_HttpNoBody(http,'GET',CkStringBuilder__getAsString(url),resp);
if (CkHttpResponse_getStatusCode(resp) = 0) then
begin
Memo1.Lines.Add('No HTTP response was received. Check connectivity and TLS settings.');
Exit;
end;
if ((success <> True) or (CkHttpResponse_getStatusCode(resp) < 200) or (CkHttpResponse_getStatusCode(resp) >= 300)) then
begin
Memo1.Lines.Add('Request failed. HTTP ' + IntToStr(CkHttpResponse_getStatusCode(resp)));
if (CkHttpResponse_getStatusCode(resp) = 429) then
begin
Memo1.Lines.Add('Rate limited. Retry-After: ' + CkHttpResponse__getHeaderField(resp,'Retry-After'));
end;
// Inspect this response locally; it can contain private Jira data.
Memo1.Lines.Add(CkHttpResponse__bodyStr(resp));
Exit;
end;
success := CkJsonObject_Load(reply,CkHttpResponse__bodyStr(resp));
if (success <> True) then
begin
Memo1.Lines.Add('Expected a JSON object in the response.');
Exit;
end;
if (CkJsonObject_JsonTypeOf(reply,'values') <> 4) then
begin
Memo1.Lines.Add('Expected an array: values');
Exit;
end;
sprintsCount := CkJsonObject_SizeOfArray(reply,'values');
sprintsIndex := 0;
while (sprintsIndex < sprintsCount) do
begin
CkJsonObject_putI(reply,sprintsIndex);
Memo1.Lines.Add('Sprint: ' + CkJsonObject__stringOf(reply,'values[i].name') + ' ' + CkJsonObject__stringOf(reply,'values[i].state') + ' ID: ' + CkJsonObject__stringOf(reply,'values[i].id'));
if (CkJsonObject_StringOfEquals(reply,'values[i].name',sprintName,True) = True) then
begin
sprintId := CkJsonObject__stringOf(reply,'values[i].id');
sprintMatches := sprintMatches + 1;
end;
sprintsIndex := sprintsIndex + 1;
end;
sprintsStart := sprintsStart + sprintsCount;
sprintsMore := (CkJsonObject_BoolOf(reply,'isLast') <> True);
if ((sprintsMore = True) and (sprintsCount = 0)) then
begin
Memo1.Lines.Add('Pagination made no progress; stopping.');
Exit;
end;
end;
if (sprintMatches <> 1) then
begin
Memo1.Lines.Add('Expected exactly one matching sprint.');
Exit;
end;
CkHttp_SetUrlVar(http,'sprintId',sprintId);
nextToken := '';
previousToken := '';
more := True;
while (more = True) do
begin
CkHttp_SetUrlVar(http,'nextToken',nextToken);
CkStringBuilder_SetString(url,baseUrl);
CkStringBuilder_Append(url,'/rest/software/1.0/sprint/{$sprintId}/issue?maxResults=50&fields=summary,status');
if (nextToken <> '') then
begin
CkStringBuilder_Append(url,'&nextPageToken={$nextToken}');
end;
success := CkHttp_HttpNoBody(http,'GET',CkStringBuilder__getAsString(url),resp);
if (CkHttpResponse_getStatusCode(resp) = 0) then
begin
Memo1.Lines.Add('No HTTP response was received. Check connectivity and TLS settings.');
Exit;
end;
if ((success <> True) or (CkHttpResponse_getStatusCode(resp) < 200) or (CkHttpResponse_getStatusCode(resp) >= 300)) then
begin
Memo1.Lines.Add('Request failed. HTTP ' + IntToStr(CkHttpResponse_getStatusCode(resp)));
if (CkHttpResponse_getStatusCode(resp) = 429) then
begin
Memo1.Lines.Add('Rate limited. Retry-After: ' + CkHttpResponse__getHeaderField(resp,'Retry-After'));
end;
// Inspect this response locally; it can contain private Jira data.
Memo1.Lines.Add(CkHttpResponse__bodyStr(resp));
Exit;
end;
success := CkJsonObject_Load(reply,CkHttpResponse__bodyStr(resp));
if (success <> True) then
begin
Memo1.Lines.Add('Expected a JSON object in the response.');
Exit;
end;
if (CkJsonObject_JsonTypeOf(reply,'issues') <> 4) then
begin
Memo1.Lines.Add('Expected an array: issues');
Exit;
end;
i := 0;
while (i < CkJsonObject_SizeOfArray(reply,'issues')) do
begin
CkJsonObject_putI(reply,i);
Memo1.Lines.Add(CkJsonObject__stringOf(reply,'issues[i].key') + ' ' + CkJsonObject__stringOf(reply,'issues[i].fields.summary'));
i := i + 1;
end;
more := (CkJsonObject_BoolOf(reply,'isLast') <> True);
if (more = True) then
begin
if ((CkJsonObject_JsonTypeOf(reply,'nextPageToken') <> 1) or (CkJsonObject_StringOfEquals(reply,'nextPageToken','',True) = True)) then
begin
Memo1.Lines.Add('Missing value: nextPageToken');
Exit;
end;
nextToken := CkJsonObject__stringOf(reply,'nextPageToken');
if (nextToken = previousToken) then
begin
Memo1.Lines.Add('Repeated pagination token; stopping.');
Exit;
end;
previousToken := nextToken;
end;
end;
CkHttp_Dispose(http);
CkStringBuilder_Dispose(url);
CkHttpResponse_Dispose(resp);
CkJsonObject_Dispose(reply);
CkStringBuilder_Dispose(boardsOffset);
CkStringBuilder_Dispose(sprintsOffset);