Chilkat Online Tools

unicodeC / WAC API / Sub-Account All Variables

Back to Collection Items

#include <C_CkHttpW.h>
#include <C_CkJsonObjectW.h>
#include <C_CkHttpResponseW.h>

void ChilkatSample(void)
    {
    HCkHttpW http;
    BOOL success;
    HCkJsonObjectW json;
    HCkHttpResponseW resp;

    // This example assumes the Chilkat API to have been previously unlocked.
    // See Global Unlock Sample for sample code.

    http = CkHttpW_Create();

    // 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
    // }

    json = CkJsonObjectW_Create();
    CkJsonObjectW_UpdateString(json,L"AcctName",L"your_customer_email@company.com");
    CkJsonObjectW_UpdateString(json,L"Password",L":C#$dXym9Gd5h%");
    CkJsonObjectW_UpdateInt(json,L"NumTrialDays",30);
    CkJsonObjectW_UpdateInt(json,L"QuotaGB",1024);
    CkJsonObjectW_UpdateBool(json,L"ConvertToPaid",FALSE);
    CkJsonObjectW_UpdateBool(json,L"ResetAccessKeys",TRUE);
    CkJsonObjectW_UpdateBool(json,L"PasswordResetRequired",TRUE);
    CkJsonObjectW_UpdateBool(json,L"EnableFTP",FALSE);
    CkJsonObjectW_UpdateBool(json,L"Inactive",FALSE);
    CkJsonObjectW_UpdateBool(json,L"SendPasswordResetToSubAccountEmail",TRUE);
    CkJsonObjectW_UpdateBool(json,L"AllowAccountDelete",FALSE);
    CkJsonObjectW_UpdateBool(json,L"DisbleMFA",FALSE);

    CkHttpW_SetRequestHeader(http,L"Authorization",L"{{WACApiKey}}");

    resp = CkHttpW_PostJson3(http,L"https://domain.com/v1/accounts/937186",L"application/json",json);
    if (CkHttpW_getLastMethodSuccess(http) == FALSE) {
        wprintf(L"%s\n",CkHttpW_lastErrorText(http));
        CkHttpW_Dispose(http);
        CkJsonObjectW_Dispose(json);
        return;
    }

    wprintf(L"%d\n",CkHttpResponseW_getStatusCode(resp));
    wprintf(L"%s\n",CkHttpResponseW_bodyStr(resp));
    CkHttpResponseW_Dispose(resp);


    CkHttpW_Dispose(http);
    CkJsonObjectW_Dispose(json);

    }

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": [
  ]
}