Delphi ActiveX Zendesk: Mark Ticket as Spam and Suspend Requester

Back to Index

Marks a ticket as SPAM and suspends the requestor.

Documentation: https://developer.zendesk.com/rest_api/docs/core/tickets#mark-ticket-as-spam-and-suspend-requester

CURL Command

curl -X PUT https://subdomain.zendesk.com/api/v2/tickets/TICKET_ID/mark_as_spam.json \
  -H "Content-Type: application/json" \
  -d '{}' \
  -H "Content-Type: application/json" \
  -u zendesk_email:zendesk_password

Delphi ActiveX Example

var
rest: TChilkatRest;
success: Integer;
bTls: Integer;
port: Integer;
bAutoReconnect: Integer;
json: TChilkatJsonObject;
sbRequestBody: TChilkatStringBuilder;
sbResponseBody: TChilkatStringBuilder;
respStatusCode: Integer;

begin
rest := TChilkatRest.Create(Self);

//  URL: https://subdomain.zendesk.com/api/v2/tickets/TICKET_ID/mark_as_spam.json
bTls := 1;
port := 443;
bAutoReconnect := 1;
success := rest.Connect('subdomain.zendesk.com',port,bTls,bAutoReconnect);
if (success <> 1) then
  begin
    Memo1.Lines.Add('ConnectFailReason: ' + IntToStr(rest.ConnectFailReason));
    Memo1.Lines.Add(rest.LastErrorText);
    Exit;
  end;

rest.SetAuthBasic('zendesk_email','zendesk_password');

json := TChilkatJsonObject.Create(Self);

rest.AddHeader('Content-Type','application/json');

sbRequestBody := TChilkatStringBuilder.Create(Self);
json.EmitSb(sbRequestBody.ControlInterface);
sbResponseBody := TChilkatStringBuilder.Create(Self);
success := rest.FullRequestSb('PUT','/api/v2/tickets/TICKET_ID/mark_as_spam.json',sbRequestBody.ControlInterface,sbResponseBody.ControlInterface);
if (success <> 1) then
  begin
    Memo1.Lines.Add(rest.LastErrorText);
    Exit;
  end;
respStatusCode := rest.ResponseStatusCode;
if (respStatusCode >= 400) then
  begin
    Memo1.Lines.Add('Response Status Code = ' + IntToStr(respStatusCode));
    Memo1.Lines.Add('Response Header:');
    Memo1.Lines.Add(rest.ResponseHeader);
    Memo1.Lines.Add('Response Body:');
    Memo1.Lines.Add(sbResponseBody.GetAsString());
    Exit;
  end;