Chilkat Online Tools

SQL Server / Plivo REST API / Retrieve details of all calls

Back to Collection Items

-- Important: See this note about string length limitations for strings returned by sp_OAMethod calls.
--
CREATE PROCEDURE ChilkatSample
AS
BEGIN
    DECLARE @hr int
    DECLARE @iTmp0 int
    -- Important: Do not use nvarchar(max).  See the warning about using nvarchar(max).
    DECLARE @sTmp0 nvarchar(4000)
    -- This example assumes the Chilkat API to have been previously unlocked.
    -- See Global Unlock Sample for sample code.

    DECLARE @http int
    EXEC @hr = sp_OACreate 'Chilkat_9_5_0.Http', @http OUT
    IF @hr <> 0
    BEGIN
        PRINT 'Failed to create ActiveX component'
        RETURN
    END

    DECLARE @success int

    EXEC sp_OASetProperty @http, 'BasicAuth', 1
    EXEC sp_OASetProperty @http, 'Login', '{{auth_id}}'
    EXEC sp_OASetProperty @http, 'Password', 'password'

    DECLARE @queryParams int
    EXEC @hr = sp_OACreate 'Chilkat_9_5_0.JsonObject', @queryParams OUT

    EXEC sp_OAMethod @queryParams, 'UpdateString', @success OUT, 'subaccount', 'SAXXXXXXXXX'
    EXEC sp_OAMethod @queryParams, 'UpdateInt', @success OUT, 'limit', 5
    EXEC sp_OAMethod @queryParams, 'UpdateInt', @success OUT, 'offset', 0

    DECLARE @resp int
    EXEC sp_OAMethod @http, 'QuickRequestParams', @resp OUT, 'GET', 'https://api.plivo.com/v1/Account/<auth_id>/Call/', @queryParams
    EXEC sp_OAGetProperty @http, 'LastMethodSuccess', @iTmp0 OUT
    IF @iTmp0 = 0
      BEGIN
        EXEC sp_OAGetProperty @http, 'LastErrorText', @sTmp0 OUT
        PRINT @sTmp0
        EXEC @hr = sp_OADestroy @http
        EXEC @hr = sp_OADestroy @queryParams
        RETURN
      END

    EXEC sp_OAGetProperty @resp, 'StatusCode', @iTmp0 OUT
    PRINT @iTmp0
    EXEC sp_OAGetProperty @resp, 'BodyStr', @sTmp0 OUT
    PRINT @sTmp0
    EXEC @hr = sp_OADestroy @resp


    EXEC @hr = sp_OADestroy @http
    EXEC @hr = sp_OADestroy @queryParams


END
GO

Curl Command

curl -G -d "subaccount=SAXXXXXXXXX"
	-d "limit=5"
	-d "offset=0"
	-u '{{auth_id}}:password'
https://api.plivo.com/v1/Account/<auth_id>/Call/

Postman Collection Item JSON

{
  "name": "Retrieve details of all calls",
  "request": {
    "method": "GET",
    "header": [
    ],
    "url": {
      "raw": "https://api.plivo.com/v1/Account/{{auth_id}}/Call/?subaccount=SAXXXXXXXXX&limit=5&offset=0",
      "protocol": "https",
      "host": [
        "api",
        "plivo",
        "com"
      ],
      "path": [
        "v1",
        "Account",
        "{{auth_id}}",
        "Call",
        ""
      ],
      "query": [
        {
          "key": "subaccount",
          "value": "SAXXXXXXXXX",
          "description": "The ID of the subaccount in case you would like to retrieve only calls made from a specific subaccount."
        },
        {
          "key": "call_direction",
          "value": "outbound",
          "description": "The direction of the call in case you would like to filter results by call direction. The valid values are ‘inbound’ and ‘outbound’",
          "disabled": true
        },
        {
          "key": "from_number",
          "value": "14152225555",
          "description": "The number from which the calls were made in case you would like to filter results by the number from which the call was made. You can filter the details by using the exact number or the desired prefix",
          "disabled": true
        },
        {
          "key": "to_number\n",
          "value": "14152223333",
          "description": "The destination number to which the calls were made in case you would like to filter results by destination called.You can filter the details by using the exact number or the desired prefix",
          "disabled": true
        },
        {
          "key": "parent_call_uuid",
          "value": "eba53b9e-8fbd-45c1-9444-696d2172fbc8",
          "description": "Set this request parameter to the Call UUID of an A-Leg to fetch all the B-Legs associated with it.",
          "disabled": true
        },
        {
          "key": "bill_duration",
          "value": "924",
          "description": "Filter the results according to billed duration. The value of billed duration is in seconds.",
          "disabled": true
        },
        {
          "key": "end_time",
          "value": "2015-07-26 15:45",
          "description": "Filter calls by their completion time.",
          "disabled": true
        },
        {
          "key": "hangup_cause_code",
          "value": "2020",
          "description": "hangup_cause_code",
          "disabled": true
        },
        {
          "key": "hangup_source",
          "value": "Plivo",
          "description": "hangup_source",
          "disabled": true
        },
        {
          "key": "limit",
          "value": "5",
          "description": "Limits the number of results retrieved. The maximum it can be set to is 20. The default value is 20 as well."
        },
        {
          "key": "offset",
          "value": "0",
          "description": "Denotes the number of value items by which the results should be offset. E.g., If the result contains a 1000 values and limit is set to 10 and offset is set to 705, then values 706 through 715 are displayed in the results. This parameter is also used for pagination of the results."
        }
      ]
    },
    "description": "This method allows you to retrieve details of all completed calls. The maximum number of results that can be fetched with a single API call is 20.\n\nBelow is the list of arguments that can be passed in this API request, more information can be found [here](https://www.plivo.com/docs/voice/api/call#retrieve-all-calls)\n\n|Arguments   | Description | Required/Conditional/Optional     |\n| :---        |    :----:   |          ---: |\n| subaccount      | The ID of the subaccount in case you would like to retrieve only calls made from a specific subaccount.| Optional  |\n| call_direction      | The direction of the call in case you would like to filter results by call direction. The valid values are ‘inbound’ and ‘outbound’.| Optional  |\n| from_number      | The number from which the calls were made in case you would like to filter results by the number from which the call was made. You can filter the details by using the exact number or the desired prefix. | Optional  |\n| to_number      | The destination number to which the calls were made in case you would like to filter results by destination called.You can filter the details by using the exact number or the desired prefix. | Optional  |\n| parent_call_uuid   | Set this request parameter to the Call UUID of an A-Leg to fetch all the B-Legs associated with it. | Optional  |\n| bill_duration      | Filter the results according to billed duration. The value of billed duration is in seconds. The filter can be used in one of the following five forms: <br />bill_duration: Input the exact value. E.g., to filter out calls that were exactly three minutes long, use bill_duration=180<br />bill_duration__gt: gt stands for greater than. E.g., to filter out calls that were more than two hours in duration bill_duration__gt=7200<br />bill_duration__gte: gte stands for greater than or equal to. E.g., to filter out calls that were two hours or more in duration bill_duration__gte=7200<br />bill_duration__lt: lt stands for lesser than. E.g., to filter out calls that were less than seven minutes in duration bill_duration__lt=420<br />bill_duration__lte: lte stands for lesser than or equal to. E.g., to filter out calls that were two hours or less in duration bill_duration__lte=7200 | Optional  |\n| end_time  | Filter calls by their completion time. The filter can be used in the following five forms:<br />end_time: The format expected is YYYY-MM-DD HH:MM[:ss[.uuuuuu]]. E.g., To get all calls that ended at 2012-03-21 11:47[:30], use end_time=2012-03-21 11:47[:30]<br />end_time__gt: gt stands for greater than. The format expected is YYYY-MM-DD HH:MM[:ss[.uuuuuu]]. E.g., To get all calls that ended after 2012-03-21 11:47, use end_time__gt=2012-03-21 11:47<br />end_time__gte: gte stands for greater than or equal. The format expected is YYYY-MM-DD HH:MM[:ss[.uuuuuu]]. E.g., To get all calls that ended after or exactly at 2012-03-21 11:47[:30], use end_time__gte=2012-03-21 11:47[:30]<br />end_time__lt: lt stands for lesser than. The format expected is YYYY-MM-DD HH:MM[:ss[.uuuuuu]]. E.g., To get all calls that ended before 2012-03-21 11:47, use end_time__lt=2012-03-21 11:47<br />end_time__lte: lte stands for lesser than or equal. The format expected is YYYY-MM-DD HH:MM[:ss[.uuuuuu]].E.g., To get all calls that ended before or exactly at 2012-03-21 11:47[:30], use end_time__lte=2012-03-21 11:47[:30] | Optional  |\n| hangup_cause_code   | Use this argument to retrieve calls that were hung up with a specific hangup cause. Refer to [this guide](https://www.plivo.com/docs/voice/troubleshooting/hangup-causes/) for a comprehensive list of hangup causes and sources. | Optional  |\n| hangup_cause_code   | Use this argument to retrieve calls that were hung up with a specific hangup cause. Refer to [this guide](https://www.plivo.com/docs/voice/troubleshooting/hangup-causes/) for a comprehensive list of hangup causes and sources. | Optional  |\n| hangup_source   | Use this argument to retrieve calls that were hung up by a specific hangup source. Refer to [this guide](https://www.plivo.com/docs/voice/troubleshooting/hangup-causes/) for a comprehensive list of hangup causes and sources. | Optional  |\n| limit   | Limits the number of results retrieved. The maximum it can be set to is 20. The default value is 20 as well. | Optional  |\n| offset   | Denotes the number of value items by which the results should be offset. E.g., If the result contains a 1000 values and limit is set to 10 and offset is set to 705, then values 706 through 715 are displayed in the results. This parameter is also used for pagination of the results. | Optional  |"
  },
  "response": [
    {
      "name": "Retrieve details of all calls",
      "originalRequest": {
        "method": "GET",
        "header": [
        ],
        "url": {
          "raw": "https://api.plivo.com/v1/Account/{{auth_id}}/Call/?subaccount=SAXXXXXXXXX&limit=5&offset=0",
          "protocol": "https",
          "host": [
            "api",
            "plivo",
            "com"
          ],
          "path": [
            "v1",
            "Account",
            "{{auth_id}}",
            "Call",
            ""
          ],
          "query": [
            {
              "key": "subaccount",
              "value": "SAXXXXXXXXX",
              "description": "The ID of the subaccount in case you would like to retrieve only calls made from a specific subaccount."
            },
            {
              "key": "call_direction",
              "value": "outbound",
              "description": "The direction of the call in case you would like to filter results by call direction. The valid values are ‘inbound’ and ‘outbound’",
              "disabled": true
            },
            {
              "key": "from_number",
              "value": "14152225555",
              "description": "The number from which the calls were made in case you would like to filter results by the number from which the call was made. You can filter the details by using the exact number or the desired prefix",
              "disabled": true
            },
            {
              "key": "to_number\n",
              "value": "14152223333",
              "description": "The destination number to which the calls were made in case you would like to filter results by destination called.You can filter the details by using the exact number or the desired prefix",
              "disabled": true
            },
            {
              "key": "parent_call_uuid",
              "value": "eba53b9e-8fbd-45c1-9444-696d2172fbc8",
              "description": "Set this request parameter to the Call UUID of an A-Leg to fetch all the B-Legs associated with it.",
              "disabled": true
            },
            {
              "key": "bill_duration",
              "value": "924",
              "description": "Filter the results according to billed duration. The value of billed duration is in seconds.",
              "disabled": true
            },
            {
              "key": "end_time",
              "value": "2015-07-26 15:45",
              "description": "Filter calls by their completion time.",
              "disabled": true
            },
            {
              "key": "hangup_cause_code",
              "value": "2020",
              "description": "hangup_cause_code",
              "disabled": true
            },
            {
              "key": "hangup_source",
              "value": "Plivo",
              "description": "hangup_source",
              "disabled": true
            },
            {
              "key": "limit",
              "value": "5",
              "description": "Limits the number of results retrieved. The maximum it can be set to is 20. The default value is 20 as well."
            },
            {
              "key": "offset",
              "value": "0",
              "description": "Denotes the number of value items by which the results should be offset. E.g., If the result contains a 1000 values and limit is set to 10 and offset is set to 705, then values 706 through 715 are displayed in the results. This parameter is also used for pagination of the results."
            }
          ]
        }
      },
      "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}"
    }
  ]
}