Jira Cloud: Discover Service Desks and Request Types
See more Jira Examples
List accessible service desks, find one by its project key, list its request types, and retrieve the required fields for a request type selected by name. Use the returned service desk ID and request type ID in the customer-request creation example.
Request types are portal-facing forms and are not interchangeable with Jira issue types. Their fields, allowed values, and required flags can differ from the platform create-issue metadata. Access depends on the account's customer or agent role. OAuth integrations need the Service Management scopes documented for these operations.
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 *projectKey = @"SUPPORT";
NSString *requestTypeName = @"General request";
NSString *serviceDeskId = @"";
NSString *requestTypeId = @"";
int deskMatches = 0;
int typeMatches = 0;
int desksStart = 0;
BOOL desksMore = YES;
CkoStringBuilder *desksOffset = [[CkoStringBuilder alloc] init];
while ((desksMore == YES)) {
[desksOffset Clear];
[desksOffset AppendInt: [NSNumber numberWithInt: desksStart]];
[http SetUrlVar: @"offset" value: [desksOffset GetAsString]];
[url SetString: baseUrl];
[url Append: @"/rest/servicedeskapi/servicedesk?start={$offset}&limit=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 desksCount = [[reply SizeOfArray: @"values"] intValue];
int desksIndex = 0;
while ((desksIndex < desksCount)) {
reply.I = [NSNumber numberWithInt: desksIndex];
NSLog(@"%@%@%@%@%@",[reply StringOf: @"values[i].projectKey"],@" ",[reply StringOf: @"values[i].projectName"],@" Service desk ID: ",[reply StringOf: @"values[i].id"]);
if ([reply StringOfEquals: @"values[i].projectKey" value: projectKey caseSensitive: YES] == YES) {
serviceDeskId = [reply StringOf: @"values[i].id"];
deskMatches = deskMatches + 1;
}
desksIndex = desksIndex + 1;
}
desksStart = desksStart + desksCount;
desksMore = ([reply BoolOf: @"isLastPage"] != YES);
if ((desksMore == YES) && (desksCount == 0)) {
NSLog(@"%@",@"Pagination made no progress; stopping.");
return;
}
}
if (deskMatches != 1) {
NSLog(@"%@",@"Expected exactly one matching service desk.");
return;
}
[http SetUrlVar: @"serviceDeskId" value: serviceDeskId];
int typesStart = 0;
BOOL typesMore = YES;
CkoStringBuilder *typesOffset = [[CkoStringBuilder alloc] init];
while ((typesMore == YES)) {
[typesOffset Clear];
[typesOffset AppendInt: [NSNumber numberWithInt: typesStart]];
[http SetUrlVar: @"offset" value: [typesOffset GetAsString]];
[url SetString: baseUrl];
[url Append: @"/rest/servicedeskapi/servicedesk/{$serviceDeskId}/requesttype?start={$offset}&limit=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 typesCount = [[reply SizeOfArray: @"values"] intValue];
int typesIndex = 0;
while ((typesIndex < typesCount)) {
reply.I = [NSNumber numberWithInt: typesIndex];
NSLog(@"%@%@%@%@",@"Request type: ",[reply StringOf: @"values[i].name"],@" ID: ",[reply StringOf: @"values[i].id"]);
if ([reply StringOfEquals: @"values[i].name" value: requestTypeName caseSensitive: YES] == YES) {
requestTypeId = [reply StringOf: @"values[i].id"];
typeMatches = typeMatches + 1;
}
typesIndex = typesIndex + 1;
}
typesStart = typesStart + typesCount;
typesMore = ([reply BoolOf: @"isLastPage"] != YES);
if ((typesMore == YES) && (typesCount == 0)) {
NSLog(@"%@",@"Pagination made no progress; stopping.");
return;
}
}
if (typeMatches != 1) {
NSLog(@"%@",@"Expected exactly one matching request type.");
return;
}
[http SetUrlVar: @"requestTypeId" value: requestTypeId];
[url SetString: baseUrl];
[url Append: @"/rest/servicedeskapi/servicedesk/{$serviceDeskId}/requesttype/{$requestTypeId}/field"];
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: @"requestTypeFields"] intValue] != 4) {
NSLog(@"%@",@"Expected an array: requestTypeFields");
return;
}
int i = 0;
while ((i < [[reply SizeOfArray: @"requestTypeFields"] intValue])) {
reply.I = [NSNumber numberWithInt: i];
NSLog(@"%@%@%@%@%d",[reply StringOf: @"requestTypeFields[i].fieldId"],@" ",[reply StringOf: @"requestTypeFields[i].name"],@" Required: ",[reply BoolOf: @"requestTypeFields[i].required"]);
i = i + 1;
}
// Includes validValues and field schemas for constructing the request.
NSLog(@"%@",[reply Emit]);
NSLog(@"%@%@%@%@",@"Service desk ID: ",serviceDeskId,@" Request type ID: ",requestTypeId);