Objective-C Jira - Issues: Delete an Issue

Back to Index

Deletes an issue. This example deletes the issue having key = "SCRUM-13". A successful delete is indicated by a response status code equal to 204 with an empty response body. This example demonstrates one possible JSON error response (where the response status code was 403).

Documentation: https://developers.atlassian.com/cloud/jira/platform/rest/#api-api-2-issue-issueIdOrKey-delete

CURL Command

curl -X DELETE --user jira@example.com:JIRA_API_TOKEN \
  --header 'Accept: application/json' \
  --url 'https://your-domain.atlassian.net/rest/api/2/issue/SCRUM-13'

Objective-C Example

#import <CkoRest.h>
#import <CkoStringBuilder.h>
#import <CkoJsonObject.h>
#import <NSString.h>

CkoRest *rest = [[CkoRest alloc] init];
BOOL success;

//  URL: https://your-domain.atlassian.net/rest/api/2/issue/SCRUM-13
BOOL bTls = YES;
int port = 443;
BOOL bAutoReconnect = YES;
success = [rest Connect: @"your-domain.atlassian.net" port: [NSNumber numberWithInt: port] tls: bTls autoReconnect: bAutoReconnect];
if (success != YES) {
    NSLog(@"%@%d",@"ConnectFailReason: ",[rest.ConnectFailReason intValue]);
    NSLog(@"%@",rest.LastErrorText);
    return;
}

[rest SetAuthBasic: @"jira@example.com" password: @"JIRA_API_TOKEN"];

[rest AddHeader: @"Accept" value: @"application/json"];

CkoStringBuilder *sbResponseBody = [[CkoStringBuilder alloc] init];
success = [rest FullRequestNoBodySb: @"DELETE" uriPath: @"/rest/api/2/issue/SCRUM-13" sb: sbResponseBody];
if (success != YES) {
    NSLog(@"%@",rest.LastErrorText);
    return;
}

int respStatusCode = [rest.ResponseStatusCode intValue];
if (respStatusCode >= 400) {
    NSLog(@"%@%d",@"Response Status Code = ",respStatusCode);
    NSLog(@"%@",@"Response Header:");
    NSLog(@"%@",rest.ResponseHeader);
    NSLog(@"%@",@"Response Body:");
    NSLog(@"%@",[sbResponseBody GetAsString]);
    return;
}

CkoJsonObject *jsonResponse = [[CkoJsonObject alloc] init];
[jsonResponse LoadSb: sbResponseBody];

int i;
int count_i;
NSString *strVal = 0;

i = 0;
count_i = [[jsonResponse SizeOfArray: @"errorMessages"] intValue];
while (i < count_i) {
    jsonResponse.I = [NSNumber numberWithInt: i];
    strVal = [jsonResponse StringOf: @"errorMessages[i]"];
    i = i + 1;
}

Sample JSON Response Body

{
  "errorMessages": [
    "You do not have permission to delete issues in this project."
  ],
  "errors": {}
}