Chilkat Online Tools

unicodeC / Support API / Delete User

Back to Collection Items

#include <C_CkHttpW.h>
#include <C_CkHttpResponseW.h>
#include <C_CkStringBuilderW.h>
#include <C_CkJsonObjectW.h>

void ChilkatSample(void)
    {
    HCkHttpW http;
    BOOL success;
    HCkHttpResponseW resp;
    HCkStringBuilderW sbResponseBody;
    HCkJsonObjectW jResp;
    int respStatusCode;
    const wchar_t *Name;
    const wchar_t *Active;
    const wchar_t *Alias;
    const wchar_t *Chat_only;
    const wchar_t *Created_at;
    const wchar_t *Custom_role_id;
    const wchar_t *Default_group_id;
    const wchar_t *Details;
    const wchar_t *v_Email;
    const wchar_t *External_id;
    const wchar_t *Iana_time_zone;
    const wchar_t *Id;
    const wchar_t *Last_login_at;
    const wchar_t *Locale;
    const wchar_t *Locale_id;
    const wchar_t *Moderator;
    const wchar_t *Notes;
    const wchar_t *Only_private_comments;
    const wchar_t *Organization_id;
    const wchar_t *Phone;
    BOOL Dolorea1;
    const wchar_t *Deserunt3;
    const wchar_t *Remote_photo_url;
    const wchar_t *Report_csv;
    const wchar_t *Restricted_agent;
    const wchar_t *Role;
    const wchar_t *Role_type;
    const wchar_t *v_Shared;
    const wchar_t *Shared_agent;
    const wchar_t *Shared_phone_number;
    const wchar_t *Signature;
    const wchar_t *Suspended;
    const wchar_t *Tags;
    const wchar_t *Ticket_restriction;
    const wchar_t *Time_zone;
    const wchar_t *Two_factor_auth_enabled;
    const wchar_t *Updated_at;
    const wchar_t *v_Url;
    const wchar_t *Nostrudacc;
    const wchar_t *In_80e;
    BOOL Proident_e2;
    int Voluptate_98;
    const wchar_t *Verified;

    // This example assumes the Chilkat API to have been previously unlocked.
    // See Global Unlock Sample for sample code.

    http = CkHttpW_Create();

    CkHttpW_putBasicAuth(http,TRUE);
    CkHttpW_putLogin(http,L"login");
    CkHttpW_putPassword(http,L"password");

    CkHttpW_SetRequestHeader(http,L"Accept",L"application/json");

    resp = CkHttpW_QuickRequest(http,L"DELETE",L"https://example.zendesk.com/api/v2/users/:user_id");
    if (CkHttpW_getLastMethodSuccess(http) == FALSE) {
        wprintf(L"%s\n",CkHttpW_lastErrorText(http));
        CkHttpW_Dispose(http);
        return;
    }

    sbResponseBody = CkStringBuilderW_Create();
    CkHttpResponseW_GetBodySb(resp,sbResponseBody);

    jResp = CkJsonObjectW_Create();
    CkJsonObjectW_LoadSb(jResp,sbResponseBody);
    CkJsonObjectW_putEmitCompact(jResp,FALSE);

    wprintf(L"Response Body:\n");
    wprintf(L"%s\n",CkJsonObjectW_emit(jResp));

    respStatusCode = CkHttpResponseW_getStatusCode(resp);
    wprintf(L"Response Status Code = %d\n",respStatusCode);
    if (respStatusCode >= 400) {
        wprintf(L"Response Header:\n");
        wprintf(L"%s\n",CkHttpResponseW_header(resp));
        wprintf(L"Failed.\n");
        CkHttpResponseW_Dispose(resp);
        CkHttpW_Dispose(http);
        CkStringBuilderW_Dispose(sbResponseBody);
        CkJsonObjectW_Dispose(jResp);
        return;
    }

    CkHttpResponseW_Dispose(resp);

    // Sample JSON response:
    // (Sample code for parsing the JSON response is shown below)

    // {
    //   "user": {
    //     "name": "<string>",
    //     "active": "<boolean>",
    //     "alias": "<string>",
    //     "chat_only": "<boolean>",
    //     "created_at": "<string>",
    //     "custom_role_id": "<integer>",
    //     "default_group_id": "<integer>",
    //     "details": "<string>",
    //     "email": "<string>",
    //     "external_id": "<string>",
    //     "iana_time_zone": "<string>",
    //     "id": "<integer>",
    //     "last_login_at": "<string>",
    //     "locale": "<string>",
    //     "locale_id": "<integer>",
    //     "moderator": "<boolean>",
    //     "notes": "<string>",
    //     "only_private_comments": "<boolean>",
    //     "organization_id": "<integer>",
    //     "phone": "<string>",
    //     "photo": {
    //       "dolorea1": false,
    //       "deserunt3": 95124319.10825741
    //     },
    //     "remote_photo_url": "<string>",
    //     "report_csv": "<boolean>",
    //     "restricted_agent": "<boolean>",
    //     "role": "<string>",
    //     "role_type": "<integer>",
    //     "shared": "<boolean>",
    //     "shared_agent": "<boolean>",
    //     "shared_phone_number": "<boolean>",
    //     "signature": "<string>",
    //     "suspended": "<boolean>",
    //     "tags": "<array>",
    //     "ticket_restriction": "<string>",
    //     "time_zone": "<string>",
    //     "two_factor_auth_enabled": "<boolean>",
    //     "updated_at": "<string>",
    //     "url": "<string>",
    //     "user_fields": {
    //       "nostrudacc": -12929960.546221554,
    //       "in_80e": 25167751.960886702,
    //       "proident_e2": true,
    //       "voluptate_98": -58995022
    //     },
    //     "verified": "<boolean>"
    //   }
    // }

    // Sample code for parsing the JSON response...
    // Use this online tool to generate parsing code from sample JSON: Generate JSON Parsing Code

    // Chilkat functions returning "const char *" return a pointer to temporary internal memory owned and managed by Chilkat.

    Name = CkJsonObjectW_stringOf(jResp,L"user.name");
    Active = CkJsonObjectW_stringOf(jResp,L"user.active");
    Alias = CkJsonObjectW_stringOf(jResp,L"user.alias");
    Chat_only = CkJsonObjectW_stringOf(jResp,L"user.chat_only");
    Created_at = CkJsonObjectW_stringOf(jResp,L"user.created_at");
    Custom_role_id = CkJsonObjectW_stringOf(jResp,L"user.custom_role_id");
    Default_group_id = CkJsonObjectW_stringOf(jResp,L"user.default_group_id");
    Details = CkJsonObjectW_stringOf(jResp,L"user.details");
    v_Email = CkJsonObjectW_stringOf(jResp,L"user.email");
    External_id = CkJsonObjectW_stringOf(jResp,L"user.external_id");
    Iana_time_zone = CkJsonObjectW_stringOf(jResp,L"user.iana_time_zone");
    Id = CkJsonObjectW_stringOf(jResp,L"user.id");
    Last_login_at = CkJsonObjectW_stringOf(jResp,L"user.last_login_at");
    Locale = CkJsonObjectW_stringOf(jResp,L"user.locale");
    Locale_id = CkJsonObjectW_stringOf(jResp,L"user.locale_id");
    Moderator = CkJsonObjectW_stringOf(jResp,L"user.moderator");
    Notes = CkJsonObjectW_stringOf(jResp,L"user.notes");
    Only_private_comments = CkJsonObjectW_stringOf(jResp,L"user.only_private_comments");
    Organization_id = CkJsonObjectW_stringOf(jResp,L"user.organization_id");
    Phone = CkJsonObjectW_stringOf(jResp,L"user.phone");
    Dolorea1 = CkJsonObjectW_BoolOf(jResp,L"user.photo.dolorea1");
    Deserunt3 = CkJsonObjectW_stringOf(jResp,L"user.photo.deserunt3");
    Remote_photo_url = CkJsonObjectW_stringOf(jResp,L"user.remote_photo_url");
    Report_csv = CkJsonObjectW_stringOf(jResp,L"user.report_csv");
    Restricted_agent = CkJsonObjectW_stringOf(jResp,L"user.restricted_agent");
    Role = CkJsonObjectW_stringOf(jResp,L"user.role");
    Role_type = CkJsonObjectW_stringOf(jResp,L"user.role_type");
    v_Shared = CkJsonObjectW_stringOf(jResp,L"user.shared");
    Shared_agent = CkJsonObjectW_stringOf(jResp,L"user.shared_agent");
    Shared_phone_number = CkJsonObjectW_stringOf(jResp,L"user.shared_phone_number");
    Signature = CkJsonObjectW_stringOf(jResp,L"user.signature");
    Suspended = CkJsonObjectW_stringOf(jResp,L"user.suspended");
    Tags = CkJsonObjectW_stringOf(jResp,L"user.tags");
    Ticket_restriction = CkJsonObjectW_stringOf(jResp,L"user.ticket_restriction");
    Time_zone = CkJsonObjectW_stringOf(jResp,L"user.time_zone");
    Two_factor_auth_enabled = CkJsonObjectW_stringOf(jResp,L"user.two_factor_auth_enabled");
    Updated_at = CkJsonObjectW_stringOf(jResp,L"user.updated_at");
    v_Url = CkJsonObjectW_stringOf(jResp,L"user.url");
    Nostrudacc = CkJsonObjectW_stringOf(jResp,L"user.user_fields.nostrudacc");
    In_80e = CkJsonObjectW_stringOf(jResp,L"user.user_fields.in_80e");
    Proident_e2 = CkJsonObjectW_BoolOf(jResp,L"user.user_fields.proident_e2");
    Voluptate_98 = CkJsonObjectW_IntOf(jResp,L"user.user_fields.voluptate_98");
    Verified = CkJsonObjectW_stringOf(jResp,L"user.verified");


    CkHttpW_Dispose(http);
    CkStringBuilderW_Dispose(sbResponseBody);
    CkJsonObjectW_Dispose(jResp);

    }

Curl Command

curl  -u login:password -X DELETE
	-H "Accept: application/json"
https://example.zendesk.com/api/v2/users/:user_id

Postman Collection Item JSON

{
  "name": "Delete User",
  "request": {
    "method": "DELETE",
    "header": [
      {
        "key": "Accept",
        "value": "application/json"
      }
    ],
    "url": {
      "raw": "{{baseUrl}}/api/v2/users/:user_id",
      "host": [
        "{{baseUrl}}"
      ],
      "path": [
        "api",
        "v2",
        "users",
        ":user_id"
      ],
      "variable": [
        {
          "key": "user_id",
          "value": "<integer>"
        }
      ]
    },
    "description": "Deletes the user and associated records from the account.\n\n**Warning**: Deleted users are not recoverable.\n\nTo comply with GDPR, a further step is needed. See [Permanently Delete User](/api-reference/ticketing/users/users/#permanently-delete-user).\n\n#### Allowed For\n\n* Agents, with restrictions on certain actions\n"
  },
  "response": [
    {
      "name": "Success response",
      "originalRequest": {
        "method": "DELETE",
        "header": [
          {
            "description": "Added as a part of security scheme: basic",
            "key": "Authorization",
            "value": "Basic <credentials>"
          }
        ],
        "url": {
          "raw": "{{baseUrl}}/api/v2/users/:user_id",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "v2",
            "users",
            ":user_id"
          ],
          "variable": [
            {
              "key": "user_id"
            }
          ]
        }
      },
      "status": "OK",
      "code": 200,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Content-Type",
          "value": "application/json"
        }
      ],
      "cookie": [
      ],
      "body": "{\n  \"user\": {\n    \"name\": \"<string>\",\n    \"active\": \"<boolean>\",\n    \"alias\": \"<string>\",\n    \"chat_only\": \"<boolean>\",\n    \"created_at\": \"<string>\",\n    \"custom_role_id\": \"<integer>\",\n    \"default_group_id\": \"<integer>\",\n    \"details\": \"<string>\",\n    \"email\": \"<string>\",\n    \"external_id\": \"<string>\",\n    \"iana_time_zone\": \"<string>\",\n    \"id\": \"<integer>\",\n    \"last_login_at\": \"<string>\",\n    \"locale\": \"<string>\",\n    \"locale_id\": \"<integer>\",\n    \"moderator\": \"<boolean>\",\n    \"notes\": \"<string>\",\n    \"only_private_comments\": \"<boolean>\",\n    \"organization_id\": \"<integer>\",\n    \"phone\": \"<string>\",\n    \"photo\": {\n      \"dolorea1\": false,\n      \"deserunt3\": 95124319.10825741\n    },\n    \"remote_photo_url\": \"<string>\",\n    \"report_csv\": \"<boolean>\",\n    \"restricted_agent\": \"<boolean>\",\n    \"role\": \"<string>\",\n    \"role_type\": \"<integer>\",\n    \"shared\": \"<boolean>\",\n    \"shared_agent\": \"<boolean>\",\n    \"shared_phone_number\": \"<boolean>\",\n    \"signature\": \"<string>\",\n    \"suspended\": \"<boolean>\",\n    \"tags\": \"<array>\",\n    \"ticket_restriction\": \"<string>\",\n    \"time_zone\": \"<string>\",\n    \"two_factor_auth_enabled\": \"<boolean>\",\n    \"updated_at\": \"<string>\",\n    \"url\": \"<string>\",\n    \"user_fields\": {\n      \"nostrudacc\": -12929960.546221554,\n      \"in_80e\": 25167751.960886702,\n      \"proident_e2\": true,\n      \"voluptate_98\": -58995022\n    },\n    \"verified\": \"<boolean>\"\n  }\n}"
    }
  ]
}