Chilkat Online Tools

VB6 / Plivo REST API / Get Call Detail Record (CDR) of a call

Back to Collection Items

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

Dim http As New ChilkatHttp
Dim success As Long

http.BasicAuth = 1
http.Login = "{{auth_id}}"
http.Password = "password"

' Use this online tool to generate code from sample JSON: Generate Code to Create JSON

' The following JSON is sent in the request body.

' {
'   "legs": "aleg",
'   "aleg_url": "https://aleg.url",
'   "aleg_method": "POST",
'   "bleg_url": "https://aleg.url",
'   "bleg_method": "POST"
' }

Dim json As New ChilkatJsonObject
success = json.UpdateString("legs","aleg")
success = json.UpdateString("aleg_url","https://aleg.url")
success = json.UpdateString("aleg_method","POST")
success = json.UpdateString("bleg_url","https://aleg.url")
success = json.UpdateString("bleg_method","POST")

Dim sbRequestBody As New ChilkatStringBuilder
success = json.EmitSb(sbRequestBody)

Dim resp As ChilkatHttpResponse
Set resp = http.PTextSb("GET","https://api.plivo.com/v1/Account/<auth_id>/Call/{call_uuid}/",sbRequestBody,"utf-8","application/json",0,0)
If (http.LastMethodSuccess = 0) Then
    Debug.Print http.LastErrorText
    Exit Sub
End If

Debug.Print resp.StatusCode
Debug.Print resp.BodyStr

Curl Command

curl -X GET
	-u '{{auth_id}}:password'
	-d '{
    "legs":"aleg",
    "aleg_url":"https://aleg.url",
    "aleg_method":"POST",
    "bleg_url":"https://aleg.url",
    "bleg_method":"POST"
}'
https://api.plivo.com/v1/Account/<auth_id>/Call/{call_uuid}/

Postman Collection Item JSON

{
  "name": "Get Call Detail Record (CDR) of a call",
  "protocolProfileBehavior": {
    "disableBodyPruning": true
  },
  "request": {
    "method": "GET",
    "header": [
    ],
    "body": {
      "mode": "raw",
      "raw": "{\n    \"legs\":\"aleg\",\n    \"aleg_url\":\"https://aleg.url\",\n    \"aleg_method\":\"POST\",\n    \"bleg_url\":\"https://aleg.url\",\n    \"bleg_method\":\"POST\"\n}",
      "options": {
        "raw": {
          "language": "json"
        }
      }
    },
    "url": {
      "raw": "https://api.plivo.com/v1/Account/{{auth_id}}/Call/{call_uuid}/",
      "protocol": "https",
      "host": [
        "api",
        "plivo",
        "com"
      ],
      "path": [
        "v1",
        "Account",
        "{{auth_id}}",
        "Call",
        "{call_uuid}",
        ""
      ]
    },
    "description": "This method allows you to retrieve the Call Detail Record (CDR) of the call. More information can be found [here](https://www.plivo.com/docs/voice/api/call#retrieve-a-call)"
  },
  "response": [
    {
      "name": "Get Call Detail Record (CDR) of a call",
      "originalRequest": {
        "method": "GET",
        "header": [
        ],
        "url": {
          "raw": "https://api.plivo.com/v1/Account/{{auth_id}}/Call/{call_uuid}/",
          "protocol": "https",
          "host": [
            "api",
            "plivo",
            "com"
          ],
          "path": [
            "v1",
            "Account",
            "{{auth_id}}",
            "Call",
            "{call_uuid}",
            ""
          ]
        }
      },
      "code": 200,
      "_postman_previewlanguage": "json",
      "header": [
      ],
      "cookie": [
      ],
      "body": "{\n    \"answer_time\": \"2015-07-26 15:45:02+05:30\",\n    \"api_id\": \"06ae0f8f-dc72-11e5-b56c-22000ae90795\",\n    \"bill_duration\": 924,\n    \"billed_duration\": 960,\n    \"call_direction\": \"outbound\",\n    \"call_duration\": 924,\n    \"call_uuid\": \"eba53b9e-8fbd-45c1-9444-696d2172fbc8\",\n    \"end_time\": \"2015-07-26 15:45:14+05:30\",\n    \"from_number\": \"+14158572518\",\n    \"initiation_time\": \"2015-07-26 15:44:49+05:30\",\n    \"parent_call_uuid\": null,\n    \"resource_uri\": \"/v1/Account/MAXXXXXXXXXXXXXXXXXX/Call/eba53b9e-8fbd-45c1-9444-696d2172fbc8/\",\n    \"to_number\": \"14153268174\",\n    \"total_amount\": \"0.13600\",\n    \"total_rate\": \"0.00850\",\n    \"hangup_cause_name\": \"End Of XML Instructions\",\n    \"hangup_cause_code\": 4010,\n    \"hangup_source\": \"Plivo\"\n}"
    }
  ]
}