Perl 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

Perl Example

use chilkat();

$rest = chilkat::CkRest->new();

#  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) {
    print "ConnectFailReason: " . $rest->get_ConnectFailReason() . "\r\n";
    print $rest->lastErrorText() . "\r\n";
    exit;
}

$rest->SetAuthBasic("zendesk_email","zendesk_password");

$json = chilkat::CkJsonObject->new();

$rest->AddHeader("Content-Type","application/json");

$sbRequestBody = chilkat::CkStringBuilder->new();
$json->EmitSb($sbRequestBody);
$sbResponseBody = chilkat::CkStringBuilder->new();
$success = $rest->FullRequestSb("PUT","/api/v2/tickets/TICKET_ID/mark_as_spam.json",$sbRequestBody,$sbResponseBody);
if ($success != 1) {
    print $rest->lastErrorText() . "\r\n";
    exit;
}

$respStatusCode = $rest->get_ResponseStatusCode();
if ($respStatusCode >= 400) {
    print "Response Status Code = " . $respStatusCode . "\r\n";
    print "Response Header:" . "\r\n";
    print $rest->responseHeader() . "\r\n";
    print "Response Body:" . "\r\n";
    print $sbResponseBody->getAsString() . "\r\n";
    exit;
}