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 Unicode C++ Downloads
#include <CkHttpW.h>
#include <CkStringBuilderW.h>
#include <CkHttpResponseW.h>
#include <CkJsonObjectW.h>
void ChilkatSample(void)
{
bool success = false;
// Assumes Chilkat is unlocked. See Global Unlock Sample.
CkHttpW http;
http.put_RequireSslCertVerify(true);
http.put_BasicAuth(true);
// Read these credentials from private application configuration.
http.put_Login(L"YOUR_ATLASSIAN_EMAIL");
http.put_Password(L"YOUR_API_TOKEN");
const wchar_t *baseUrl = L"https://your-domain.atlassian.net";
http.put_Accept(L"application/json");
CkStringBuilderW url;
CkHttpResponseW resp;
CkJsonObjectW reply;
const wchar_t *boardName = L"Example Board";
const wchar_t *sprintName = L"Sprint 1";
const wchar_t *boardId = L"";
const wchar_t *sprintId = L"";
int boardMatches = 0;
int sprintMatches = 0;
http.SetUrlVar(L"projectKey",L"PROJECT");
http.SetUrlVar(L"boardName",boardName);
// Team-managed boards can have type simple, including boards with sprints enabled.
int boardsStart = 0;
bool boardsMore = true;
CkStringBuilderW boardsOffset;
while ((boardsMore == true)) {
boardsOffset.Clear();
boardsOffset.AppendInt(boardsStart);
http.SetUrlVar(L"offset",boardsOffset.getAsString());
url.SetString(baseUrl);
url.Append(L"/rest/agile/1.0/board?projectKeyOrId={$projectKey}&name={$boardName}&startAt={$offset}&maxResults=50");
success = http.HttpNoBody(L"GET",url.getAsString(),resp);
if (resp.get_StatusCode() == 0) {
wprintf(L"No HTTP response was received. Check connectivity and TLS settings.\n");
return;
}
if ((success != true) || (resp.get_StatusCode() < 200) || (resp.get_StatusCode() >= 300)) {
wprintf(L"Request failed. HTTP %d\n",resp.get_StatusCode());
if (resp.get_StatusCode() == 429) {
wprintf(L"Rate limited. Retry-After: %s\n",resp.getHeaderField(L"Retry-After"));
}
// Inspect this response locally; it can contain private Jira data.
wprintf(L"%s\n",resp.bodyStr());
return;
}
success = reply.Load(resp.bodyStr());
if (success != true) {
wprintf(L"Expected a JSON object in the response.\n");
return;
}
if (reply.JsonTypeOf(L"values") != 4) {
wprintf(L"Expected an array: values\n");
return;
}
int boardsCount = reply.SizeOfArray(L"values");
int boardsIndex = 0;
while ((boardsIndex < boardsCount)) {
reply.put_I(boardsIndex);
wprintf(L"Board: %s ID: %s\n",reply.stringOf(L"values[i].name"),reply.stringOf(L"values[i].id"));
if (reply.StringOfEquals(L"values[i].name",boardName,true) == true) {
boardId = reply.stringOf(L"values[i].id");
boardMatches = boardMatches + 1;
}
boardsIndex = boardsIndex + 1;
}
boardsStart = boardsStart + boardsCount;
boardsMore = (reply.BoolOf(L"isLast") != true);
if ((boardsMore == true) && (boardsCount == 0)) {
wprintf(L"Pagination made no progress; stopping.\n");
return;
}
}
if (boardMatches != 1) {
wprintf(L"Expected exactly one matching board in this project.\n");
return;
}
http.SetUrlVar(L"boardId",boardId);
int sprintsStart = 0;
bool sprintsMore = true;
CkStringBuilderW sprintsOffset;
while ((sprintsMore == true)) {
sprintsOffset.Clear();
sprintsOffset.AppendInt(sprintsStart);
http.SetUrlVar(L"offset",sprintsOffset.getAsString());
url.SetString(baseUrl);
url.Append(L"/rest/agile/1.0/board/{$boardId}/sprint?startAt={$offset}&maxResults=50");
success = http.HttpNoBody(L"GET",url.getAsString(),resp);
if (resp.get_StatusCode() == 0) {
wprintf(L"No HTTP response was received. Check connectivity and TLS settings.\n");
return;
}
if ((success != true) || (resp.get_StatusCode() < 200) || (resp.get_StatusCode() >= 300)) {
wprintf(L"Request failed. HTTP %d\n",resp.get_StatusCode());
if (resp.get_StatusCode() == 429) {
wprintf(L"Rate limited. Retry-After: %s\n",resp.getHeaderField(L"Retry-After"));
}
// Inspect this response locally; it can contain private Jira data.
wprintf(L"%s\n",resp.bodyStr());
return;
}
success = reply.Load(resp.bodyStr());
if (success != true) {
wprintf(L"Expected a JSON object in the response.\n");
return;
}
if (reply.JsonTypeOf(L"values") != 4) {
wprintf(L"Expected an array: values\n");
return;
}
int sprintsCount = reply.SizeOfArray(L"values");
int sprintsIndex = 0;
while ((sprintsIndex < sprintsCount)) {
reply.put_I(sprintsIndex);
wprintf(L"Sprint: %s %s ID: %s\n",reply.stringOf(L"values[i].name"),reply.stringOf(L"values[i].state"),reply.stringOf(L"values[i].id"));
if (reply.StringOfEquals(L"values[i].name",sprintName,true) == true) {
sprintId = reply.stringOf(L"values[i].id");
sprintMatches = sprintMatches + 1;
}
sprintsIndex = sprintsIndex + 1;
}
sprintsStart = sprintsStart + sprintsCount;
sprintsMore = (reply.BoolOf(L"isLast") != true);
if ((sprintsMore == true) && (sprintsCount == 0)) {
wprintf(L"Pagination made no progress; stopping.\n");
return;
}
}
if (sprintMatches != 1) {
wprintf(L"Expected exactly one matching sprint.\n");
return;
}
http.SetUrlVar(L"sprintId",sprintId);
const wchar_t *nextToken = L"";
const wchar_t *previousToken = L"";
bool more = true;
while ((more == true)) {
http.SetUrlVar(L"nextToken",nextToken);
url.SetString(baseUrl);
url.Append(L"/rest/software/1.0/sprint/{$sprintId}/issue?maxResults=50&fields=summary,status");
if (nextToken != L"") {
url.Append(L"&nextPageToken={$nextToken}");
}
success = http.HttpNoBody(L"GET",url.getAsString(),resp);
if (resp.get_StatusCode() == 0) {
wprintf(L"No HTTP response was received. Check connectivity and TLS settings.\n");
return;
}
if ((success != true) || (resp.get_StatusCode() < 200) || (resp.get_StatusCode() >= 300)) {
wprintf(L"Request failed. HTTP %d\n",resp.get_StatusCode());
if (resp.get_StatusCode() == 429) {
wprintf(L"Rate limited. Retry-After: %s\n",resp.getHeaderField(L"Retry-After"));
}
// Inspect this response locally; it can contain private Jira data.
wprintf(L"%s\n",resp.bodyStr());
return;
}
success = reply.Load(resp.bodyStr());
if (success != true) {
wprintf(L"Expected a JSON object in the response.\n");
return;
}
if (reply.JsonTypeOf(L"issues") != 4) {
wprintf(L"Expected an array: issues\n");
return;
}
int i = 0;
while ((i < reply.SizeOfArray(L"issues"))) {
reply.put_I(i);
wprintf(L"%s %s\n",reply.stringOf(L"issues[i].key"),reply.stringOf(L"issues[i].fields.summary"));
i = i + 1;
}
more = (reply.BoolOf(L"isLast") != true);
if (more == true) {
if ((reply.JsonTypeOf(L"nextPageToken") != 1) || (reply.StringOfEquals(L"nextPageToken",L"",true) == true)) {
wprintf(L"Missing value: nextPageToken\n");
return;
}
nextToken = reply.stringOf(L"nextPageToken");
if (nextToken == previousToken) {
wprintf(L"Repeated pagination token; stopping.\n");
return;
}
previousToken = nextToken;
}
}
}