Delphi DLL 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'

Delphi DLL Example

var
rest: HCkRest;
success: Boolean;
bTls: Boolean;
port: Integer;
bAutoReconnect: Boolean;
sbResponseBody: HCkStringBuilder;
respStatusCode: Integer;
jsonResponse: HCkJsonObject;
i: Integer;
count_i: Integer;
strVal: PWideChar;

begin
rest := CkRest_Create();

//  URL: https://your-domain.atlassian.net/rest/api/2/issue/SCRUM-13
bTls := True;
port := 443;
bAutoReconnect := True;
success := CkRest_Connect(rest,'your-domain.atlassian.net',port,bTls,bAutoReconnect);
if (success <> True) then
  begin
    Memo1.Lines.Add('ConnectFailReason: ' + IntToStr(CkRest_getConnectFailReason(rest)));
    Memo1.Lines.Add(CkRest__lastErrorText(rest));
    Exit;
  end;

CkRest_SetAuthBasic(rest,'jira@example.com','JIRA_API_TOKEN');

CkRest_AddHeader(rest,'Accept','application/json');

sbResponseBody := CkStringBuilder_Create();
success := CkRest_FullRequestNoBodySb(rest,'DELETE','/rest/api/2/issue/SCRUM-13',sbResponseBody);
if (success <> True) then
  begin
    Memo1.Lines.Add(CkRest__lastErrorText(rest));
    Exit;
  end;
respStatusCode := CkRest_getResponseStatusCode(rest);
if (respStatusCode >= 400) then
  begin
    Memo1.Lines.Add('Response Status Code = ' + IntToStr(respStatusCode));
    Memo1.Lines.Add('Response Header:');
    Memo1.Lines.Add(CkRest__responseHeader(rest));
    Memo1.Lines.Add('Response Body:');
    Memo1.Lines.Add(CkStringBuilder__getAsString(sbResponseBody));
    Exit;
  end;

jsonResponse := CkJsonObject_Create();
CkJsonObject_LoadSb(jsonResponse,sbResponseBody);

i := 0;
count_i := CkJsonObject_SizeOfArray(jsonResponse,'errorMessages');
while i < count_i do
  begin
CkJsonObject_putI(jsonResponse,i);
    strVal := CkJsonObject__stringOf(jsonResponse,'errorMessages[i]');
    i := i + 1;
  end;

CkRest_Dispose(rest);
CkStringBuilder_Dispose(sbResponseBody);
CkJsonObject_Dispose(jsonResponse);

Sample JSON Response Body

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