SQL Server / WAC API / Sub-Account All Variables
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
-- Use this online tool to generate code from sample JSON: Generate Code to Create JSON
-- The following JSON is sent in the request body.
-- {
-- "AcctName": "your_customer_email@company.com",
-- "Password": ":C#$d\{Xym9Gd5h%",
-- "NumTrialDays": 30,
-- "QuotaGB": 1024,
-- "ConvertToPaid": false,
-- "ResetAccessKeys": true,
-- "PasswordResetRequired": true,
-- "EnableFTP": false,
-- "Inactive": false,
-- "SendPasswordResetToSubAccountEmail": true,
-- "AllowAccountDelete": false,
-- "DisbleMFA": false
-- }
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, 'AcctName', 'your_customer_email@company.com'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'Password', ':C#$dXym9Gd5h%'
EXEC sp_OAMethod @json, 'UpdateInt', @success OUT, 'NumTrialDays', 30
EXEC sp_OAMethod @json, 'UpdateInt', @success OUT, 'QuotaGB', 1024
EXEC sp_OAMethod @json, 'UpdateBool', @success OUT, 'ConvertToPaid', 0
EXEC sp_OAMethod @json, 'UpdateBool', @success OUT, 'ResetAccessKeys', 1
EXEC sp_OAMethod @json, 'UpdateBool', @success OUT, 'PasswordResetRequired', 1
EXEC sp_OAMethod @json, 'UpdateBool', @success OUT, 'EnableFTP', 0
EXEC sp_OAMethod @json, 'UpdateBool', @success OUT, 'Inactive', 0
EXEC sp_OAMethod @json, 'UpdateBool', @success OUT, 'SendPasswordResetToSubAccountEmail', 1
EXEC sp_OAMethod @json, 'UpdateBool', @success OUT, 'AllowAccountDelete', 0
EXEC sp_OAMethod @json, 'UpdateBool', @success OUT, 'DisbleMFA', 0
EXEC sp_OAMethod @http, 'SetRequestHeader', NULL, 'Authorization', '{{WACApiKey}}'
DECLARE @resp int
EXEC sp_OAMethod @http, 'PostJson3', @resp OUT, 'https://domain.com/v1/accounts/937186', '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
-H "Authorization: {{WACApiKey}}"
-d '{
"AcctName": "your_customer_email@company.com",
"Password": ":C#$d\{Xym9Gd5h%",
"NumTrialDays": 30,
"QuotaGB": 1024,
"ConvertToPaid": false,
"ResetAccessKeys": true,
"PasswordResetRequired": true,
"EnableFTP": false,
"Inactive": false,
"SendPasswordResetToSubAccountEmail": true,
"AllowAccountDelete": false,
"DisbleMFA": false
}'
https://domain.com/v1/accounts/937186
Postman Collection Item JSON
{
"name": "Sub-Account All Variables",
"request": {
"method": "POST",
"header": [
{
"key": "Authorization",
"value": "{{WACApiKey}}",
"type": "text"
}
],
"body": {
"mode": "raw",
"raw": "{\r\n \"AcctName\": \"your_customer_email@company.com\",\r\n \"Password\": \":C#$d\\{Xym9Gd5h%\",\r\n \"NumTrialDays\": 30,\r\n \"QuotaGB\": 1024,\r\n \"ConvertToPaid\": false,\r\n \"ResetAccessKeys\": true,\r\n \"PasswordResetRequired\": true,\r\n \"EnableFTP\": false,\r\n \"Inactive\": false,\r\n \"SendPasswordResetToSubAccountEmail\": true,\r\n \"AllowAccountDelete\": false,\r\n \"DisbleMFA\": false\r\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "{{baseURL}}/v1/accounts/937186",
"host": [
"{{baseURL}}"
],
"path": [
"v1",
"accounts",
"937186"
]
}
},
"response": [
]
}