Chilkat Online Tools

SQL Server / Plivo REST API / List all Numbers

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, 'starts_with', ''
    EXEC sp_OAMethod @queryParams, 'UpdateString', @success OUT, 'type', ''
    EXEC sp_OAMethod @queryParams, 'UpdateString', @success OUT, 'service', ''
    EXEC sp_OAMethod @queryParams, 'UpdateString', @success OUT, 'country_iso2', ''
    EXEC sp_OAMethod @queryParams, 'UpdateString', @success OUT, 'limit', ''
    EXEC sp_OAMethod @queryParams, 'UpdateString', @success OUT, 'offset', ''

    DECLARE @resp int
    EXEC sp_OAMethod @http, 'QuickRequestParams', @resp OUT, 'GET', 'https://api.plivo.com/v1/Account/<auth_id>/NumberPool/{number_pool_uuid}/Number/', @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 "starts_with="
	-d "type="
	-d "service="
	-d "country_iso2="
	-d "limit="
	-d "offset="
	-u '{{auth_id}}:password'
https://api.plivo.com/v1/Account/<auth_id>/NumberPool/{number_pool_uuid}/Number/

Postman Collection Item JSON

{
  "name": "List all Numbers",
  "request": {
    "method": "GET",
    "header": [
    ],
    "url": {
      "raw": "https://api.plivo.com/v1/Account/{{auth_id}}/NumberPool/{number_pool_uuid}/Number/?starts_with=&type=&service=&country_iso2=&limit=&offset=",
      "protocol": "https",
      "host": [
        "api",
        "plivo",
        "com"
      ],
      "path": [
        "v1",
        "Account",
        "{{auth_id}}",
        "NumberPool",
        "{number_pool_uuid}",
        "Number",
        ""
      ],
      "query": [
        {
          "key": "starts_with",
          "value": "",
          "description": "A comma separated list of prefixes.\nAssume the values provided exclude the country code prefix.\nA max of 10 prefixes may be specified."
        },
        {
          "key": "type",
          "value": "",
          "description": "fixed, tollfree or mobile. Note that local and national numbers should be considered as ‘fixed’"
        },
        {
          "key": "service",
          "value": "",
          "description": "sms or mms. Use this argument to filter the numbers by capability."
        },
        {
          "key": "country_iso2",
          "value": "",
          "description": "ISO2 code of the phone number country.\nThis attribute must be specified if starts_with filter has been specified."
        },
        {
          "key": "limit",
          "value": "",
          "description": "Used to display the number of results per page. The maximum number of results that can be fetched is 20. Defaults to 20."
        },
        {
          "key": "offset",
          "value": "",
          "description": "Denotes the number of value items by which the results should be offset"
        }
      ]
    },
    "description": "This API can be used to fetch a list of numbers from the Number Pool based on number_pool_UUID specified in the resource URI. More information can be found [here](https://www.plivo.com/docs/sms/api/numberpool#list-all-numbers)\n\n| Arguments   | Description | Required/Conditional/Optional |\n| :---:       |    :----:   |          :---: |\n| starts_with | A comma separated list of prefixes. Assume the values provided exclude the country code prefix. A max of 10 prefixes may be specified. Throw 400 Bad Request if more than 10 prefixes are specified.| Optional  |\n| type | fixed, tollfree or mobile. Note that local and national numbers should be considered as ‘fixed’ | Optional  |\n| service | sms or mms. Use this argument to filter the numbers by capability. | Optional  |\n| country_iso2 | ISO2 code of the phone number country. This attribute must be specified if starts_with filter has been specified. | Conditional  |\n| limit | Used to display the number of results per page. The maximum number of results that can be fetched is 20. Defaults to 20. | Optional  |\n| offset | Denotes the number of value items by which the results should be offset. | Optional  |"
  },
  "response": [
    {
      "name": "List all Numbers",
      "originalRequest": {
        "method": "GET",
        "header": [
        ],
        "url": {
          "raw": "https://api.plivo.com/v1/Account/{{auth_id}}/NumberPool/{number_pool_uuid}/Number/?starts_with&type&service&country_iso2&limit&offset",
          "protocol": "https",
          "host": [
            "api",
            "plivo",
            "com"
          ],
          "path": [
            "v1",
            "Account",
            "{{auth_id}}",
            "NumberPool",
            "{number_pool_uuid}",
            "Number",
            ""
          ],
          "query": [
            {
              "key": "starts_with",
              "value": null,
              "description": "A comma separated list of prefixes.\nAssume the values provided exclude the country code prefix.\nA max of 10 prefixes may be specified."
            },
            {
              "key": "type",
              "value": null,
              "description": "fixed, tollfree or mobile. Note that local and national numbers should be considered as ‘fixed’"
            },
            {
              "key": "service",
              "value": null,
              "description": "sms or mms. Use this argument to filter the numbers by capability."
            },
            {
              "key": "country_iso2",
              "value": null,
              "description": "ISO2 code of the phone number country.\nThis attribute must be specified if starts_with filter has been specified."
            },
            {
              "key": "limit",
              "value": null,
              "description": "Used to display the number of results per page. The maximum number of results that can be fetched is 20. Defaults to 20."
            },
            {
              "key": "offset",
              "value": null,
              "description": "Denotes the number of value items by which the results should be offset"
            }
          ]
        }
      },
      "code": 200,
      "_postman_previewlanguage": "json",
      "header": [
      ],
      "cookie": [
      ],
      "body": "{\n  \"api_id\": \"06c15d7c-7ed5-11ea-855f-0242ac110003\",\n  \"meta\": {\n    \"limit\": 20,\n    \"next\": \"\",\n    \"offset\": 0,\n    \"previous\": \"\",\n    \"total_count\": 1\n  },\n  \"objects\": [\n    {\n      \"account_phone_number_resource\": \"/v1/Account/{auth_id}/Number/{your_number}/\",\n      \"added_on\": \"2020-03-18T16:07:39.379739Z\",\n      \"country_iso2\": \"US\",\n      \"number\": \"{your_number}\",\n      \"number_pool_uuid\": \"{number_pool_uuid}\",\n      \"service\": \"mms\",\n      \"type\": \"fixed\"\n    },\n   {\n      \"account_phone_number_resource\": \"/v1/Account/{auth_id}/Number/{your_number}/\",\n      \"added_on\": \"2020-03-18T16:07:39.379739Z\",\n      \"country_iso2\": \"US\",\n      \"number\": \"{your_number}\",\n      \"number_pool_uuid\": \"{number_pool_uuid}\",\n      \"service\": \"sms\",\n      \"type\": \"fixed\"\n    }\n    {\n      \"account_phone_number_resource\": \"/v1/Account/{auth_id}/Number/{your_number}/\",\n      \"added_on\": \"2019-10-09T11:24:35.085797Z\",\n      \"country_iso2\": \"CA\",\n      \"number\": \"{your_number}\",\n      \"number_pool_uuid\": \"{number_pool_uuid}\",\n      \"service\": \"sms\",\n      \"type\": \"fixed\"\n    }\n  ]\n}"
    }
  ]
}