Chilkat Online Tools

unicodeCpp / Trader v2 API / Account Configurations

Back to Collection Items

#include <CkHttpW.h>
#include <CkJsonObjectW.h>
#include <CkStringBuilderW.h>
#include <CkHttpResponseW.h>

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

    CkHttpW http;
    bool success;

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

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

    // {
    //   "max_margin_multiplier": 1.0
    // }

    CkJsonObjectW json;
    json.UpdateNumber(L"max_margin_multiplier",L"1.0");

    http.SetRequestHeader(L"Apca-Api-Secret-Key",L"{{APCA_API_SECRET_KEY}}");
    http.SetRequestHeader(L"Apca-Api-Key-Id",L"{{APCA_API_KEY_ID}}");

    CkStringBuilderW sbRequestBody;
    json.EmitSb(sbRequestBody);

    CkHttpResponseW *resp = http.PTextSb(L"GET",L"https://domain.com/v2/account/configurations",sbRequestBody,L"utf-8",L"application/json",false,false);
    if (http.get_LastMethodSuccess() == false) {
        wprintf(L"%s\n",http.lastErrorText());
        return;
    }

    wprintf(L"%d\n",resp->get_StatusCode());
    wprintf(L"%s\n",resp->bodyStr());
    delete resp;
    }

Curl Command

curl -X GET
	-H "Apca-Api-Key-Id: {{APCA_API_KEY_ID}}"
	-H "Apca-Api-Secret-Key: {{APCA_API_SECRET_KEY}}"
	-d '{
  "max_margin_multiplier": 1.0
}'
https://domain.com/v2/account/configurations

Postman Collection Item JSON

{
  "name": "Account Configurations",
  "protocolProfileBehavior": {
    "disableBodyPruning": true
  },
  "request": {
    "method": "GET",
    "header": [
      {
        "key": "Apca-Api-Key-Id",
        "value": "{{APCA_API_KEY_ID}}",
        "type": "text"
      },
      {
        "key": "Apca-Api-Secret-Key",
        "value": "{{APCA_API_SECRET_KEY}}",
        "type": "text"
      }
    ],
    "body": {
      "mode": "raw",
      "raw": "{\n  \"max_margin_multiplier\": 1.0\n}",
      "options": {
        "raw": {
          "language": "json"
        }
      }
    },
    "url": {
      "raw": "{{HOST}}/v2/account/configurations",
      "host": [
        "{{HOST}}"
      ],
      "path": [
        "v2",
        "account",
        "configurations"
      ]
    }
  },
  "response": [
  ]
}