C# UWP/WinRT 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

C# UWP/WinRT Example

Chilkat.Rest rest = new Chilkat.Rest();
bool success;

//  URL: https://subdomain.zendesk.com/api/v2/tickets/TICKET_ID/mark_as_spam.json
bool bTls = true;
int port = 443;
bool bAutoReconnect = true;
success = await rest.ConnectAsync("subdomain.zendesk.com",port,bTls,bAutoReconnect);
if (success != true) {
    Debug.WriteLine("ConnectFailReason: " + Convert.ToString(rest.ConnectFailReason));
    Debug.WriteLine(rest.LastErrorText);
    return;
}

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

Chilkat.JsonObject json = new Chilkat.JsonObject();

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

Chilkat.StringBuilder sbRequestBody = new Chilkat.StringBuilder();
json.EmitSb(sbRequestBody);
Chilkat.StringBuilder sbResponseBody = new Chilkat.StringBuilder();
success = await rest.FullRequestSbAsync("PUT","/api/v2/tickets/TICKET_ID/mark_as_spam.json",sbRequestBody,sbResponseBody);
if (success != true) {
    Debug.WriteLine(rest.LastErrorText);
    return;
}

int respStatusCode = rest.ResponseStatusCode;
if (respStatusCode >= 400) {
    Debug.WriteLine("Response Status Code = " + Convert.ToString(respStatusCode));
    Debug.WriteLine("Response Header:");
    Debug.WriteLine(rest.ResponseHeader);
    Debug.WriteLine("Response Body:");
    Debug.WriteLine(sbResponseBody.GetAsString());
    return;
}