Chilkat Online Tools

delphiDll / Support API / Verify Identity

Back to Collection Items

var
http: HCkHttp;
success: Boolean;
resp: HCkHttpResponse;
sbResponseBody: HCkStringBuilder;
jResp: HCkJsonObject;
respStatusCode: Integer;
User_id: PWideChar;
v_Type: PWideChar;
Value: PWideChar;
Created_at: PWideChar;
Deliverable_state: PWideChar;
Id: PWideChar;
Primary: PWideChar;
Undeliverable_count: PWideChar;
Updated_at: PWideChar;
v_Url: PWideChar;
Verified: PWideChar;

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

http := CkHttp_Create();

CkHttp_putBasicAuth(http,True);
CkHttp_putLogin(http,'login');
CkHttp_putPassword(http,'password');

CkHttp_SetRequestHeader(http,'Accept','application/json');

resp := CkHttp_QuickRequest(http,'PUT','https://example.zendesk.com/api/v2/users/:user_id/identities/:user_identity_id/verify');
if (CkHttp_getLastMethodSuccess(http) = False) then
  begin
    Memo1.Lines.Add(CkHttp__lastErrorText(http));
    Exit;
  end;

sbResponseBody := CkStringBuilder_Create();
CkHttpResponse_GetBodySb(resp,sbResponseBody);

jResp := CkJsonObject_Create();
CkJsonObject_LoadSb(jResp,sbResponseBody);
CkJsonObject_putEmitCompact(jResp,False);

Memo1.Lines.Add('Response Body:');
Memo1.Lines.Add(CkJsonObject__emit(jResp));

respStatusCode := CkHttpResponse_getStatusCode(resp);
Memo1.Lines.Add('Response Status Code = ' + IntToStr(respStatusCode));
if (respStatusCode >= 400) then
  begin
    Memo1.Lines.Add('Response Header:');
    Memo1.Lines.Add(CkHttpResponse__header(resp));
    Memo1.Lines.Add('Failed.');
    CkHttpResponse_Dispose(resp);
    Exit;
  end;
CkHttpResponse_Dispose(resp);

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

// {
//   "identity": {
//     "user_id": "<integer>",
//     "type": "google",
//     "value": "<string>",
//     "created_at": "<dateTime>",
//     "deliverable_state": "<string>",
//     "id": "<integer>",
//     "primary": "<boolean>",
//     "undeliverable_count": "<integer>",
//     "updated_at": "<dateTime>",
//     "url": "<string>",
//     "verified": "<boolean>"
//   }
// }

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

User_id := CkJsonObject__stringOf(jResp,'identity.user_id');
v_Type := CkJsonObject__stringOf(jResp,'identity.type');
Value := CkJsonObject__stringOf(jResp,'identity.value');
Created_at := CkJsonObject__stringOf(jResp,'identity.created_at');
Deliverable_state := CkJsonObject__stringOf(jResp,'identity.deliverable_state');
Id := CkJsonObject__stringOf(jResp,'identity.id');
Primary := CkJsonObject__stringOf(jResp,'identity.primary');
Undeliverable_count := CkJsonObject__stringOf(jResp,'identity.undeliverable_count');
Updated_at := CkJsonObject__stringOf(jResp,'identity.updated_at');
v_Url := CkJsonObject__stringOf(jResp,'identity.url');
Verified := CkJsonObject__stringOf(jResp,'identity.verified');

CkHttp_Dispose(http);
CkStringBuilder_Dispose(sbResponseBody);
CkJsonObject_Dispose(jResp);

Curl Command

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

Postman Collection Item JSON

{
  "name": "Verify Identity",
  "request": {
    "method": "PUT",
    "header": [
      {
        "key": "Accept",
        "value": "application/json"
      }
    ],
    "url": {
      "raw": "{{baseUrl}}/api/v2/users/:user_id/identities/:user_identity_id/verify",
      "host": [
        "{{baseUrl}}"
      ],
      "path": [
        "api",
        "v2",
        "users",
        ":user_id",
        "identities",
        ":user_identity_id",
        "verify"
      ],
      "variable": [
        {
          "key": "user_id",
          "value": "<integer>"
        },
        {
          "key": "user_identity_id",
          "value": "<integer>"
        }
      ]
    },
    "description": "Sets the specified identity as verified.\n\n#### Allowed For\n\n* Agents\n"
  },
  "response": [
    {
      "name": "Success response",
      "originalRequest": {
        "method": "PUT",
        "header": [
          {
            "description": "Added as a part of security scheme: basic",
            "key": "Authorization",
            "value": "Basic <credentials>"
          }
        ],
        "url": {
          "raw": "{{baseUrl}}/api/v2/users/:user_id/identities/:user_identity_id/verify",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "v2",
            "users",
            ":user_id",
            "identities",
            ":user_identity_id",
            "verify"
          ],
          "variable": [
            {
              "key": "user_id"
            },
            {
              "key": "user_identity_id"
            }
          ]
        }
      },
      "status": "OK",
      "code": 200,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Content-Type",
          "value": "application/json"
        }
      ],
      "cookie": [
      ],
      "body": "{\n  \"identity\": {\n    \"user_id\": \"<integer>\",\n    \"type\": \"google\",\n    \"value\": \"<string>\",\n    \"created_at\": \"<dateTime>\",\n    \"deliverable_state\": \"<string>\",\n    \"id\": \"<integer>\",\n    \"primary\": \"<boolean>\",\n    \"undeliverable_count\": \"<integer>\",\n    \"updated_at\": \"<dateTime>\",\n    \"url\": \"<string>\",\n    \"verified\": \"<boolean>\"\n  }\n}"
    }
  ]
}