Chilkat Online Tools

C# / 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.

Chilkat.Http http = new Chilkat.Http();
bool success;

http.BasicAuth = true;
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"
// }

Chilkat.JsonObject json = new Chilkat.JsonObject();
json.UpdateString("legs","aleg");
json.UpdateString("aleg_url","https://aleg.url");
json.UpdateString("aleg_method","POST");
json.UpdateString("bleg_url","https://aleg.url");
json.UpdateString("bleg_method","POST");

Chilkat.StringBuilder sbRequestBody = new Chilkat.StringBuilder();
json.EmitSb(sbRequestBody);

Chilkat.HttpResponse resp = http.PTextSb("GET","https://api.plivo.com/v1/Account/<auth_id>/Call/{call_uuid}/",sbRequestBody,"utf-8","application/json",false,false);
if (http.LastMethodSuccess == false) {
    Debug.WriteLine(http.LastErrorText);
    return;
}

Debug.WriteLine(Convert.ToString(resp.StatusCode));
Debug.WriteLine(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}"
    }
  ]
}