SQL Server / Plivo REST API / Create a Powerpack
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'
-- Use this online tool to generate code from sample JSON: Generate Code to Create JSON
-- The following JSON is sent in the request body.
-- {
-- "name": "friendly_name",
-- "sticky_sender": "True",
-- "local_connect": "True",
-- "application_type": "XML",
-- "application_id": "application_id can be found from the dashboard"
-- }
DECLARE @json int
-- Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0
EXEC @hr = sp_OACreate 'Chilkat.JsonObject', @json OUT
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'name', 'friendly_name'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'sticky_sender', 'True'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'local_connect', 'True'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'application_type', 'XML'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'application_id', 'application_id can be found from the dashboard'
DECLARE @resp int
EXEC sp_OAMethod @http, 'PostJson3', @resp OUT, 'https://api.plivo.com/v1/Account/<auth_id>/Powerpack/', 'application/json', @json
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
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
END
GO
Curl Command
curl -X POST
-u '{{auth_id}}:password'
-d '{
"name":"friendly_name",
"sticky_sender":"True",
"local_connect":"True",
"application_type":"XML",
"application_id":"application_id can be found from the dashboard"
}'
https://api.plivo.com/v1/Account/<auth_id>/Powerpack/
Postman Collection Item JSON
{
"name": "Create a Powerpack",
"request": {
"method": "POST",
"header": [
],
"body": {
"mode": "raw",
"raw": "{\n \"name\":\"friendly_name\",\n \"sticky_sender\":\"True\",\n \"local_connect\":\"True\",\n \"application_type\":\"XML\",\n \"application_id\":\"application_id can be found from the dashboard\"\n\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "https://api.plivo.com/v1/Account/{{auth_id}}/Powerpack/",
"protocol": "https",
"host": [
"api",
"plivo",
"com"
],
"path": [
"v1",
"Account",
"{{auth_id}}",
"Powerpack",
""
]
},
"description": "This API lets you to create a Powerpack via Plivo’s SMS service. Below is the list of arguments that can be passed in this API request. More information can be found [here](https://www.plivo.com/docs/sms/api/powerpack#create-a-powerpack)\n\n| Arguments | Description | Required/Conditional/Optional |\n| :--- | :----: | ---: |\n| name | Must be unique across all Powerpacks in customer's account| Required |\n| sticky_sender | Sticky sender should be enabled by default. Default value is True. Sticky Sender ensures messages to a particular destination number are always sent from the same source number | Optional |\n| local_connect | Local connect should be enabled by default. Default value is True. Local connect prioritizes local numbers matched on area code and State over other numbers in the pool | Optional |\n| application_type | Must be specified if application_id is specified| Conditional |\n| application_id | Must be set to a valid PHLO or XML App Id or 'none'(String). If not specified (or set to 'none') no application to be associated with phone numbers added to this Powerpack. | Optional |"
},
"response": [
{
"name": "Create a Powerpack",
"originalRequest": {
"method": "POST",
"header": [
],
"body": {
"mode": "raw",
"raw": "{\n \"name\":\"friendly_name\",\n \"sticky_sender\":\"True\",\n \"local_connect\":\"True\",\n \"application_type\":\"XML\",\n \"application_id\":\"application_id can be found from the dashboard\"\n\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "https://api.plivo.com/v1/Account/{{auth_id}}/Powerpack/",
"protocol": "https",
"host": [
"api",
"plivo",
"com"
],
"path": [
"v1",
"Account",
"{{auth_id}}",
"Powerpack",
""
]
}
},
"code": 200,
"_postman_previewlanguage": "json",
"header": [
],
"cookie": [
],
"body": "{\n \"api_id\": \"4b2c83c4-09ff-11ea-b072-0242ac110007\",\n \"application_id\": \"20342783288007824\",\n \"application_type\": \"XML\",\n \"created_on\": \"2019-10-09T11:10:59.666461Z\",\n \"local_connect\": true,\n \"name\": \"test\",\n \"number_pool\": \"/v1/Account/{auth_id}/NumberPool/<number_pool_uuid>/\",\n \"sticky_sender\": true,\n \"uuid\": \"<powerpack_uuid>\"\n}"
}
]
}