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 Objective-C Downloads
#import <CkoHttp.h>
#import <NSString.h>
#import <CkoStringBuilder.h>
#import <CkoHttpResponse.h>
#import <CkoJsonObject.h>
BOOL success = NO;
// Assumes Chilkat is unlocked. See Global Unlock Sample.
CkoHttp *http = [[CkoHttp alloc] init];
http.RequireSslCertVerify = YES;
http.BasicAuth = YES;
// Read these credentials from private application configuration.
http.Login = @"YOUR_ATLASSIAN_EMAIL";
http.Password = @"YOUR_API_TOKEN";
NSString *baseUrl = @"https://your-domain.atlassian.net";
http.Accept = @"application/json";
CkoStringBuilder *url = [[CkoStringBuilder alloc] init];
CkoHttpResponse *resp = [[CkoHttpResponse alloc] init];
CkoJsonObject *reply = [[CkoJsonObject alloc] init];
NSString *boardName = @"Example Board";
NSString *sprintName = @"Sprint 1";
NSString *boardId = @"";
NSString *sprintId = @"";
int boardMatches = 0;
int sprintMatches = 0;
[http SetUrlVar: @"projectKey" value: @"PROJECT"];
[http SetUrlVar: @"boardName" value: boardName];
// Team-managed boards can have type simple, including boards with sprints enabled.
int boardsStart = 0;
BOOL boardsMore = YES;
CkoStringBuilder *boardsOffset = [[CkoStringBuilder alloc] init];
while ((boardsMore == YES)) {
[boardsOffset Clear];
[boardsOffset AppendInt: [NSNumber numberWithInt: boardsStart]];
[http SetUrlVar: @"offset" value: [boardsOffset GetAsString]];
[url SetString: baseUrl];
[url Append: @"/rest/agile/1.0/board?projectKeyOrId={$projectKey}&name={$boardName}&startAt={$offset}&maxResults=50"];
success = [http HttpNoBody: @"GET" url: [url GetAsString] response: resp];
if ([resp.StatusCode intValue] == 0) {
NSLog(@"%@",@"No HTTP response was received. Check connectivity and TLS settings.");
return;
}
if ((success != YES) || ([resp.StatusCode intValue] < 200) || ([resp.StatusCode intValue] >= 300)) {
NSLog(@"%@%d",@"Request failed. HTTP ",[resp.StatusCode intValue]);
if ([resp.StatusCode intValue] == 429) {
NSLog(@"%@%@",@"Rate limited. Retry-After: ",[resp GetHeaderField: @"Retry-After"]);
}
// Inspect this response locally; it can contain private Jira data.
NSLog(@"%@",resp.BodyStr);
return;
}
success = [reply Load: resp.BodyStr];
if (success != YES) {
NSLog(@"%@",@"Expected a JSON object in the response.");
return;
}
if ([[reply JsonTypeOf: @"values"] intValue] != 4) {
NSLog(@"%@",@"Expected an array: values");
return;
}
int boardsCount = [[reply SizeOfArray: @"values"] intValue];
int boardsIndex = 0;
while ((boardsIndex < boardsCount)) {
reply.I = [NSNumber numberWithInt: boardsIndex];
NSLog(@"%@%@%@%@",@"Board: ",[reply StringOf: @"values[i].name"],@" ID: ",[reply StringOf: @"values[i].id"]);
if ([reply StringOfEquals: @"values[i].name" value: boardName caseSensitive: YES] == YES) {
boardId = [reply StringOf: @"values[i].id"];
boardMatches = boardMatches + 1;
}
boardsIndex = boardsIndex + 1;
}
boardsStart = boardsStart + boardsCount;
boardsMore = ([reply BoolOf: @"isLast"] != YES);
if ((boardsMore == YES) && (boardsCount == 0)) {
NSLog(@"%@",@"Pagination made no progress; stopping.");
return;
}
}
if (boardMatches != 1) {
NSLog(@"%@",@"Expected exactly one matching board in this project.");
return;
}
[http SetUrlVar: @"boardId" value: boardId];
int sprintsStart = 0;
BOOL sprintsMore = YES;
CkoStringBuilder *sprintsOffset = [[CkoStringBuilder alloc] init];
while ((sprintsMore == YES)) {
[sprintsOffset Clear];
[sprintsOffset AppendInt: [NSNumber numberWithInt: sprintsStart]];
[http SetUrlVar: @"offset" value: [sprintsOffset GetAsString]];
[url SetString: baseUrl];
[url Append: @"/rest/agile/1.0/board/{$boardId}/sprint?startAt={$offset}&maxResults=50"];
success = [http HttpNoBody: @"GET" url: [url GetAsString] response: resp];
if ([resp.StatusCode intValue] == 0) {
NSLog(@"%@",@"No HTTP response was received. Check connectivity and TLS settings.");
return;
}
if ((success != YES) || ([resp.StatusCode intValue] < 200) || ([resp.StatusCode intValue] >= 300)) {
NSLog(@"%@%d",@"Request failed. HTTP ",[resp.StatusCode intValue]);
if ([resp.StatusCode intValue] == 429) {
NSLog(@"%@%@",@"Rate limited. Retry-After: ",[resp GetHeaderField: @"Retry-After"]);
}
// Inspect this response locally; it can contain private Jira data.
NSLog(@"%@",resp.BodyStr);
return;
}
success = [reply Load: resp.BodyStr];
if (success != YES) {
NSLog(@"%@",@"Expected a JSON object in the response.");
return;
}
if ([[reply JsonTypeOf: @"values"] intValue] != 4) {
NSLog(@"%@",@"Expected an array: values");
return;
}
int sprintsCount = [[reply SizeOfArray: @"values"] intValue];
int sprintsIndex = 0;
while ((sprintsIndex < sprintsCount)) {
reply.I = [NSNumber numberWithInt: sprintsIndex];
NSLog(@"%@%@%@%@%@%@",@"Sprint: ",[reply StringOf: @"values[i].name"],@" ",[reply StringOf: @"values[i].state"],@" ID: ",[reply StringOf: @"values[i].id"]);
if ([reply StringOfEquals: @"values[i].name" value: sprintName caseSensitive: YES] == YES) {
sprintId = [reply StringOf: @"values[i].id"];
sprintMatches = sprintMatches + 1;
}
sprintsIndex = sprintsIndex + 1;
}
sprintsStart = sprintsStart + sprintsCount;
sprintsMore = ([reply BoolOf: @"isLast"] != YES);
if ((sprintsMore == YES) && (sprintsCount == 0)) {
NSLog(@"%@",@"Pagination made no progress; stopping.");
return;
}
}
if (sprintMatches != 1) {
NSLog(@"%@",@"Expected exactly one matching sprint.");
return;
}
[http SetUrlVar: @"sprintId" value: sprintId];
NSString *nextToken = @"";
NSString *previousToken = @"";
BOOL more = YES;
while ((more == YES)) {
[http SetUrlVar: @"nextToken" value: nextToken];
[url SetString: baseUrl];
[url Append: @"/rest/software/1.0/sprint/{$sprintId}/issue?maxResults=50&fields=summary,status"];
if (nextToken != @"") {
[url Append: @"&nextPageToken={$nextToken}"];
}
success = [http HttpNoBody: @"GET" url: [url GetAsString] response: resp];
if ([resp.StatusCode intValue] == 0) {
NSLog(@"%@",@"No HTTP response was received. Check connectivity and TLS settings.");
return;
}
if ((success != YES) || ([resp.StatusCode intValue] < 200) || ([resp.StatusCode intValue] >= 300)) {
NSLog(@"%@%d",@"Request failed. HTTP ",[resp.StatusCode intValue]);
if ([resp.StatusCode intValue] == 429) {
NSLog(@"%@%@",@"Rate limited. Retry-After: ",[resp GetHeaderField: @"Retry-After"]);
}
// Inspect this response locally; it can contain private Jira data.
NSLog(@"%@",resp.BodyStr);
return;
}
success = [reply Load: resp.BodyStr];
if (success != YES) {
NSLog(@"%@",@"Expected a JSON object in the response.");
return;
}
if ([[reply JsonTypeOf: @"issues"] intValue] != 4) {
NSLog(@"%@",@"Expected an array: issues");
return;
}
int i = 0;
while ((i < [[reply SizeOfArray: @"issues"] intValue])) {
reply.I = [NSNumber numberWithInt: i];
NSLog(@"%@%@%@",[reply StringOf: @"issues[i].key"],@" ",[reply StringOf: @"issues[i].fields.summary"]);
i = i + 1;
}
more = ([reply BoolOf: @"isLast"] != YES);
if (more == YES) {
if (([[reply JsonTypeOf: @"nextPageToken"] intValue] != 1) || ([reply StringOfEquals: @"nextPageToken" value: @"" caseSensitive: YES] == YES)) {
NSLog(@"%@",@"Missing value: nextPageToken");
return;
}
nextToken = [reply StringOf: @"nextPageToken"];
if (nextToken == previousToken) {
NSLog(@"%@",@"Repeated pagination token; stopping.");
return;
}
previousToken = nextToken;
}
}