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).
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'
#include <C_CkRestW.h>
#include <C_CkStringBuilderW.h>
#include <C_CkJsonObjectW.h>
void ChilkatSample(void)
{
HCkRestW rest;
BOOL success;
BOOL bTls;
int port;
BOOL bAutoReconnect;
HCkStringBuilderW sbResponseBody;
int respStatusCode;
HCkJsonObjectW jsonResponse;
int i;
int count_i;
const wchar_t *strVal;
rest = CkRestW_Create();
// URL: https://your-domain.atlassian.net/rest/api/2/issue/SCRUM-13
bTls = TRUE;
port = 443;
bAutoReconnect = TRUE;
success = CkRestW_Connect(rest,L"your-domain.atlassian.net",port,bTls,bAutoReconnect);
if (success != TRUE) {
wprintf(L"ConnectFailReason: %d\n",CkRestW_getConnectFailReason(rest));
wprintf(L"%s\n",CkRestW_lastErrorText(rest));
CkRestW_Dispose(rest);
return;
}
CkRestW_SetAuthBasic(rest,L"jira@example.com",L"JIRA_API_TOKEN");
CkRestW_AddHeader(rest,L"Accept",L"application/json");
sbResponseBody = CkStringBuilderW_Create();
success = CkRestW_FullRequestNoBodySb(rest,L"DELETE",L"/rest/api/2/issue/SCRUM-13",sbResponseBody);
if (success != TRUE) {
wprintf(L"%s\n",CkRestW_lastErrorText(rest));
CkRestW_Dispose(rest);
CkStringBuilderW_Dispose(sbResponseBody);
return;
}
respStatusCode = CkRestW_getResponseStatusCode(rest);
if (respStatusCode >= 400) {
wprintf(L"Response Status Code = %d\n",respStatusCode);
wprintf(L"Response Header:\n");
wprintf(L"%s\n",CkRestW_responseHeader(rest));
wprintf(L"Response Body:\n");
wprintf(L"%s\n",CkStringBuilderW_getAsString(sbResponseBody));
CkRestW_Dispose(rest);
CkStringBuilderW_Dispose(sbResponseBody);
return;
}
jsonResponse = CkJsonObjectW_Create();
CkJsonObjectW_LoadSb(jsonResponse,sbResponseBody);
i = 0;
count_i = CkJsonObjectW_SizeOfArray(jsonResponse,L"errorMessages");
while (i < count_i) {
CkJsonObjectW_putI(jsonResponse,i);
strVal = CkJsonObjectW_stringOf(jsonResponse,L"errorMessages[i]");
i = i + 1;
}
CkRestW_Dispose(rest);
CkStringBuilderW_Dispose(sbResponseBody);
CkJsonObjectW_Dispose(jsonResponse);
}
{
"errorMessages": [
"You do not have permission to delete issues in this project."
],
"errors": {}
}