Chilkat Online Tools

SQL Server / Plivo REST API / Get details of all ongoing 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
    -- Use "Chilkat_9_5_0.Http" for versions of Chilkat < 10.0.0
    EXEC @hr = sp_OACreate 'Chilkat.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
    -- Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0
    EXEC @hr = sp_OACreate 'Chilkat.JsonObject', @queryParams OUT

    EXEC sp_OAMethod @queryParams, 'UpdateString', @success OUT, 'status', 'live'
    EXEC sp_OAMethod @queryParams, 'UpdateString', @success OUT, 'call_direction', 'outbound'
    EXEC sp_OAMethod @queryParams, 'UpdateString', @success OUT, 'from_number', '14152225555'
    EXEC sp_OAMethod @queryParams, 'UpdateString', @success OUT, 'to_number', '14152223333'

    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 "status=live"
	-d "call_direction
=outbound"
	-d "from_number=14152225555"
	-d "to_number=14152223333"
	-u '{{auth_id}}:password'
https://api.plivo.com/v1/Account/<auth_id>/Call/

Postman Collection Item JSON

{
  "name": "Get details of all ongoing calls",
  "request": {
    "method": "GET",
    "header": [
    ],
    "url": {
      "raw": "https://api.plivo.com/v1/Account/{{auth_id}}/Call/?status=live&call_direction\n=outbound&from_number=14152225555&to_number=14152223333",
      "protocol": "https",
      "host": [
        "api",
        "plivo",
        "com"
      ],
      "path": [
        "v1",
        "Account",
        "{{auth_id}}",
        "Call",
        ""
      ],
      "query": [
        {
          "key": "status",
          "value": "live"
        },
        {
          "key": "call_direction\n",
          "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’."
        },
        {
          "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."
        },
        {
          "key": "to_number",
          "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.\n"
        }
      ]
    },
    "description": "This method allows you to retrieve details of all ongoing calls made from an account.\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-live-calls)\n\n| Arguments   | Description | Required/Conditional/Optional     |\n| :---        |    :----:   |          ---: |\n| call_direction      | SThe 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 |"
  },
  "response": [
    {
      "name": "Get details of all ongoing calls",
      "originalRequest": {
        "method": "GET",
        "header": [
        ],
        "url": {
          "raw": "https://api.plivo.com/v1/Account/{{auth_id}}/Call/",
          "protocol": "https",
          "host": [
            "api",
            "plivo",
            "com"
          ],
          "path": [
            "v1",
            "Account",
            "{{auth_id}}",
            "Call",
            ""
          ],
          "query": [
            {
              "key": "status",
              "value": "live",
              "disabled": true
            },
            {
              "key": "call_direction\n",
              "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",
              "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.\n",
              "disabled": true
            }
          ]
        }
      },
      "code": 200,
      "_postman_previewlanguage": "json",
      "header": [
      ],
      "cookie": [
      ],
      "body": "{\n    \"api_id\": \"c9527676-5839-11e1-86da-6ff39efcb949\",\n    \"calls\": [\n        \"eac94337-b1cd-499b-82d1-b39bca50dc31\",\n        \"0a70a7fb-168e-4944-a846-4f3f4d2f96f1\"\n    ]\n}"
    }
  ]
}