DataFlex / Support API / Show Identity
Back to Collection Items
Use ChilkatAx-win32.pkg
Procedure Test
Handle hoHttp
Boolean iSuccess
Variant vSbResponseBody
Handle hoSbResponseBody
Handle hoJResp
Integer iRespStatusCode
String sUser_id
String sV_Type
String sValue
String sCreated_at
String sDeliverable_state
String sId
String sPrimary
String sUndeliverable_count
String sUpdated_at
String sV_Url
String sVerified
String sTemp1
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
Get Create (RefClass(cComChilkatHttp)) To hoHttp
If (Not(IsComObjectCreated(hoHttp))) Begin
Send CreateComObject of hoHttp
End
Set ComBasicAuth Of hoHttp To True
Set ComLogin Of hoHttp To "login"
Set ComPassword Of hoHttp To "password"
Send ComSetRequestHeader To hoHttp "Accept" "application/json"
Get Create (RefClass(cComChilkatStringBuilder)) To hoSbResponseBody
If (Not(IsComObjectCreated(hoSbResponseBody))) Begin
Send CreateComObject of hoSbResponseBody
End
Get pvComObject of hoSbResponseBody to vSbResponseBody
Get ComQuickGetSb Of hoHttp "https://example.zendesk.com/api/v2/users/:user_id/identities/:user_identity_id" vSbResponseBody To iSuccess
If (iSuccess = False) Begin
Get ComLastErrorText Of hoHttp To sTemp1
Showln sTemp1
Procedure_Return
End
Get Create (RefClass(cComChilkatJsonObject)) To hoJResp
If (Not(IsComObjectCreated(hoJResp))) Begin
Send CreateComObject of hoJResp
End
Get pvComObject of hoSbResponseBody to vSbResponseBody
Get ComLoadSb Of hoJResp vSbResponseBody To iSuccess
Set ComEmitCompact Of hoJResp To False
Showln "Response Body:"
Get ComEmit Of hoJResp To sTemp1
Showln sTemp1
Get ComLastStatus Of hoHttp To iRespStatusCode
Showln "Response Status Code = " iRespStatusCode
If (iRespStatusCode >= 400) Begin
Showln "Response Header:"
Get ComLastHeader Of hoHttp To sTemp1
Showln sTemp1
Showln "Failed."
Procedure_Return
End
// 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
Get ComStringOf Of hoJResp "identity.user_id" To sUser_id
Get ComStringOf Of hoJResp "identity.type" To sV_Type
Get ComStringOf Of hoJResp "identity.value" To sValue
Get ComStringOf Of hoJResp "identity.created_at" To sCreated_at
Get ComStringOf Of hoJResp "identity.deliverable_state" To sDeliverable_state
Get ComStringOf Of hoJResp "identity.id" To sId
Get ComStringOf Of hoJResp "identity.primary" To sPrimary
Get ComStringOf Of hoJResp "identity.undeliverable_count" To sUndeliverable_count
Get ComStringOf Of hoJResp "identity.updated_at" To sUpdated_at
Get ComStringOf Of hoJResp "identity.url" To sV_Url
Get ComStringOf Of hoJResp "identity.verified" To sVerified
End_Procedure
Curl Command
curl -u login:password -X GET
-H "Accept: application/json"
https://example.zendesk.com/api/v2/users/:user_id/identities/:user_identity_id
Postman Collection Item JSON
{
"name": "Show Identity",
"request": {
"method": "GET",
"header": [
{
"key": "Accept",
"value": "application/json"
}
],
"url": {
"raw": "{{baseUrl}}/api/v2/users/:user_id/identities/:user_identity_id",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v2",
"users",
":user_id",
"identities",
":user_identity_id"
],
"variable": [
{
"key": "user_id",
"value": "<integer>"
},
{
"key": "user_identity_id",
"value": "<integer>"
}
]
},
"description": "Shows the identity with the given id for a given user.\n\nUse the first endpoint if authenticating as an agent. Use the second if authenticating as an end user. End users can only view email or phone number identity.\n\n#### Allowed For\n\n* Agents\n* Verified end users\n"
},
"response": [
{
"name": "Success response",
"originalRequest": {
"method": "GET",
"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",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v2",
"users",
":user_id",
"identities",
":user_identity_id"
],
"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}"
}
]
}