DataFlex / Support API / Show Session
Back to Collection Items
Use ChilkatAx-win32.pkg
Procedure Test
Handle hoHttp
Boolean iSuccess
Variant vSbResponseBody
Handle hoSbResponseBody
Handle hoJResp
Integer iRespStatusCode
String sId
String sAuthenticated_at
String sLast_seen_at
String sUrl
String sUser_id
Integer i
Integer iCount_i
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/sessions/:session_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)
// {
// "session": [
// {
// "id": "<integer>",
// "authenticated_at": "<string>",
// "last_seen_at": "<string>",
// "url": "<string>",
// "user_id": "<integer>"
// },
// {
// "id": "<integer>",
// "authenticated_at": "<string>",
// "last_seen_at": "<string>",
// "url": "<string>",
// "user_id": "<integer>"
// }
// ]
// }
// Sample code for parsing the JSON response...
// Use this online tool to generate parsing code from sample JSON: Generate JSON Parsing Code
Move 0 To i
Get ComSizeOfArray Of hoJResp "session" To iCount_i
While (i < iCount_i)
Set ComI Of hoJResp To i
Get ComStringOf Of hoJResp "session[i].id" To sId
Get ComStringOf Of hoJResp "session[i].authenticated_at" To sAuthenticated_at
Get ComStringOf Of hoJResp "session[i].last_seen_at" To sLast_seen_at
Get ComStringOf Of hoJResp "session[i].url" To sUrl
Get ComStringOf Of hoJResp "session[i].user_id" To sUser_id
Move (i + 1) To i
Loop
End_Procedure
Curl Command
curl -u login:password -X GET
-H "Accept: application/json"
https://example.zendesk.com/api/v2/users/:user_id/sessions/:session_id
Postman Collection Item JSON
{
"name": "Show Session",
"request": {
"method": "GET",
"header": [
{
"key": "Accept",
"value": "application/json"
}
],
"url": {
"raw": "{{baseUrl}}/api/v2/users/:user_id/sessions/:session_id",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v2",
"users",
":user_id",
"sessions",
":session_id"
],
"variable": [
{
"key": "user_id",
"value": "<integer>"
},
{
"key": "session_id",
"value": "<integer>"
}
]
},
"description": "#### Allowed For\n\n* Admins, Agents, 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/sessions/:session_id",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v2",
"users",
":user_id",
"sessions",
":session_id"
],
"variable": [
{
"key": "user_id"
},
{
"key": "session_id"
}
]
}
},
"status": "OK",
"code": 200,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"cookie": [
],
"body": "{\n \"session\": [\n {\n \"id\": \"<integer>\",\n \"authenticated_at\": \"<string>\",\n \"last_seen_at\": \"<string>\",\n \"url\": \"<string>\",\n \"user_id\": \"<integer>\"\n },\n {\n \"id\": \"<integer>\",\n \"authenticated_at\": \"<string>\",\n \"last_seen_at\": \"<string>\",\n \"url\": \"<string>\",\n \"user_id\": \"<integer>\"\n }\n ]\n}"
}
]
}