Chilkat Online Tools

SQL Server / Plivo REST API / Get Details of All Applications

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'

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

    -- The following JSON is sent in the request body.

    -- {
    --   "subaccount": "SAZWM0YJBHZMY1ZTK4OG",
    --   "limit": "20",
    --   "offset": "0"
    -- }

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

    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'subaccount', 'SAZWM0YJBHZMY1ZTK4OG'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'limit', '20'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'offset', '0'

    DECLARE @sbRequestBody int
    EXEC @hr = sp_OACreate 'Chilkat_9_5_0.StringBuilder', @sbRequestBody OUT

    EXEC sp_OAMethod @json, 'EmitSb', @success OUT, @sbRequestBody

    DECLARE @resp int
    EXEC sp_OAMethod @http, 'PTextSb', @resp OUT, 'GET', 'https://api.plivo.com/v1/Account/<auth_id>/Application/', @sbRequestBody, 'utf-8', 'application/json', 0, 0
    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 @json
        EXEC @hr = sp_OADestroy @sbRequestBody
        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 @json
    EXEC @hr = sp_OADestroy @sbRequestBody


END
GO

Curl Command

curl -X GET
	-u '{{auth_id}}:password'
	-d '{
    "subaccount":"SAZWM0YJBHZMY1ZTK4OG",
    "limit":"20",
    "offset":"0"

}'
https://api.plivo.com/v1/Account/<auth_id>/Application/

Postman Collection Item JSON

{
  "name": "Get Details of All Applications",
  "protocolProfileBehavior": {
    "disableBodyPruning": true
  },
  "request": {
    "method": "GET",
    "header": [
    ],
    "body": {
      "mode": "raw",
      "raw": "{\n    \"subaccount\":\"SAZWM0YJBHZMY1ZTK4OG\",\n    \"limit\":\"20\",\n    \"offset\":\"0\"\n\n}",
      "options": {
        "raw": {
          "language": "json"
        }
      }
    },
    "url": {
      "raw": "https://api.plivo.com/v1/Account/{{auth_id}}/Application/",
      "protocol": "https",
      "host": [
        "api",
        "plivo",
        "com"
      ],
      "path": [
        "v1",
        "Account",
        "{{auth_id}}",
        "Application",
        ""
      ]
    },
    "description": "This API is used to get details of all the application that have been created under your Plivo 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/account/api/application#list-all-applications)\n\n| Arguments   | Description | Required/Conditional/Optional     |\n| :---        |    :----:   |          ---: |\n| subaccount      | ID of the subaccount, in case only subaccount applications are needed.| Optional  |\n| limit   | Used to display the number of results per page. The maximum number of results that can be fetched is 20.     | Optional     |\n| offset   | Denotes the number of value items by which the results should be offset. | Optional |"
  },
  "response": [
    {
      "name": "Get Details of All Applications",
      "originalRequest": {
        "method": "GET",
        "header": [
        ],
        "url": {
          "raw": "https://api.plivo.com/v1/Account/{{auth_id}}/Application/",
          "protocol": "https",
          "host": [
            "api",
            "plivo",
            "com"
          ],
          "path": [
            "v1",
            "Account",
            "{{auth_id}}",
            "Application",
            ""
          ]
        }
      },
      "_postman_previewlanguage": "json",
      "header": [
      ],
      "cookie": [
      ],
      "body": "{\n    \"api_id\": \"3cf5a08f-4dec-11eb-8f87-0242ac110005\",\n    \"meta\": {\n        \"limit\": 20,\n        \"next\": null,\n        \"offset\": 0,\n        \"previous\": null,\n        \"total_count\": 3\n    },\n    \"objects\": [\n        {\n            \"answer_method\": \"GET\",\n            \"answer_url\": \"http://plivodirectdial.herokuapp.com/response/sip/route/?DialMusic=real&CLID=18587561234\",\n            \"app_id\": \"77506472664956327\",\n            \"app_name\": \"Direct Dial\",\n            \"application_type\": \"XML\",\n            \"default_app\": false,\n            \"default_endpoint_app\": true,\n            \"enabled\": true,\n            \"fallback_answer_url\": \"\",\n            \"fallback_method\": \"POST\",\n            \"hangup_method\": \"POST\",\n            \"hangup_url\": \"https://webhook.site/bbcd37a6-922c-4cfe-8c3f-8ea282f83702\",\n            \"log_incoming_message\": true,\n            \"message_method\": \"POST\",\n            \"message_url\": \"https://run.mocky.io/v3/33eb28f6-2a00-4a98-9235-06e1ace5728a\",\n            \"public_uri\": false,\n            \"resource_uri\": \"/v1/Account/MAMDC1NTE3ZGQ4NWNJNM/Application/77506472664956327/\",\n            \"sip_uri\": \"sip:77506472664956327@app.plivo.com\",\n            \"sub_account\": null\n        },\n        {\n            \"answer_method\": \"GET\",\n            \"answer_url\": \"https://s3.amazonaws.com/plivosamplexml/conference_url.xml\",\n            \"app_id\": \"77543232947799695\",\n            \"app_name\": \"Demo Conference\",\n            \"application_type\": \"XML\",\n            \"default_app\": false,\n            \"default_endpoint_app\": false,\n            \"enabled\": true,\n            \"fallback_answer_url\": \"\",\n            \"fallback_method\": \"POST\",\n            \"hangup_method\": \"GET\",\n            \"hangup_url\": \"https://s3.amazonaws.com/plivosamplexml/conference_url.xml\",\n            \"log_incoming_message\": true,\n            \"message_method\": \"POST\",\n            \"message_url\": \"\",\n            \"public_uri\": false,\n            \"resource_uri\": \"/v1/Account/MAMDC1NTE3ZGQ4NWNJNM/Application/77543232947799695/\",\n            \"sip_uri\": \"sip:77543232947799695@app.plivo.com\",\n            \"sub_account\": null\n        },\n        {\n            \"answer_method\": \"GET\",\n            \"answer_url\": \"https://s3.amazonaws.com/plivosamplexml/play_url.xml\",\n            \"app_id\": \"77532213102675586\",\n            \"app_name\": \"Demo Play\",\n            \"application_type\": \"XML\",\n            \"default_app\": false,\n            \"default_endpoint_app\": false,\n            \"enabled\": true,\n            \"fallback_answer_url\": null,\n            \"fallback_method\": \"POST\",\n            \"hangup_method\": \"GET\",\n            \"hangup_url\": \"https://s3.amazonaws.com/plivosamplexml/play_url.xml\",\n            \"log_incoming_message\": true,\n            \"message_method\": \"POST\",\n            \"message_url\": null,\n            \"public_uri\": false,\n            \"resource_uri\": \"/v1/Account/MAMDC1NTE3ZGQ4NWNJNM/Application/77532213102675586/\",\n            \"sip_uri\": \"sip:77532213102675586@app.plivo.com\",\n            \"sub_account\": null\n        }\n    ]\n}"
    }
  ]
}