Chilkat Online Tools

unicodeC / Bond APIs / update card restriction

Back to Collection Items

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

void ChilkatSample(void)
    {
    HCkHttpW http;
    BOOL success;
    HCkJsonObjectW json;
    HCkStringBuilderW sbRequestBody;
    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.

    // {
    //   "max_amount": ""
    // }

    json = CkJsonObjectW_Create();
    CkJsonObjectW_UpdateString(json,L"max_amount",L"");

    CkHttpW_SetRequestHeader(http,L"Content-Type",L"application/json");
    CkHttpW_SetRequestHeader(http,L"Authorization",L"{{authorization}}");
    CkHttpW_SetRequestHeader(http,L"Identity",L"{{identity}}");

    sbRequestBody = CkStringBuilderW_Create();
    CkJsonObjectW_EmitSb(json,sbRequestBody);

    resp = CkHttpW_PTextSb(http,L"PATCH",L"https://{{environment}}.bond.tech/api/v0/cards/{{card_id}}/restrictions",sbRequestBody,L"utf-8",L"application/json",FALSE,FALSE);
    if (CkHttpW_getLastMethodSuccess(http) == FALSE) {
        wprintf(L"%s\n",CkHttpW_lastErrorText(http));
        CkHttpW_Dispose(http);
        CkJsonObjectW_Dispose(json);
        CkStringBuilderW_Dispose(sbRequestBody);
        return;
    }

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


    CkHttpW_Dispose(http);
    CkJsonObjectW_Dispose(json);
    CkStringBuilderW_Dispose(sbRequestBody);

    }

Curl Command

curl -X PATCH
	-H "Content-Type: application/json"
	-H "Authorization: {{authorization}}"
	-H "Identity: {{identity}}"
	-d '{
    "max_amount": ""
}'
https://{{environment}}.bond.tech/api/v0/cards/{{card_id}}/restrictions

Postman Collection Item JSON

{
  "name": "update card restriction",
  "request": {
    "method": "PATCH",
    "header": [
      {
        "key": "Content-Type",
        "type": "text",
        "value": "application/json"
      },
      {
        "key": "Authorization",
        "type": "text",
        "value": "{{authorization}}"
      },
      {
        "key": "Identity",
        "type": "text",
        "value": "{{identity}}"
      }
    ],
    "body": {
      "mode": "raw",
      "raw": "{\n    \"max_amount\": \"\"\n}"
    },
    "url": {
      "raw": "https://{{environment}}.bond.tech/api/v0/cards/{{card_id}}/restrictions",
      "protocol": "https",
      "host": [
        "{{environment}}",
        "bond",
        "tech"
      ],
      "path": [
        "api",
        "v0",
        "cards",
        "{{card_id}}",
        "restrictions"
      ]
    },
    "description": "Add Card financial Core"
  },
  "response": [
    {
      "name": "update card restriction",
      "originalRequest": {
        "method": "PATCH",
        "header": [
          {
            "key": "Content-Type",
            "name": "Content-Type",
            "value": "application/json",
            "type": "text"
          },
          {
            "key": "Authorization",
            "type": "text",
            "value": "{{authorization}}"
          },
          {
            "key": "Identity",
            "type": "text",
            "value": "{{identity}}"
          }
        ],
        "body": {
          "mode": "raw",
          "raw": "{\n    \"max_amount\": \"50000\"\n}",
          "options": {
            "raw": {
              "language": "json"
            }
          }
        },
        "url": {
          "raw": "https://{{environment}}.bond.tech/api/v0/cards/{{card_id}}/restrictions",
          "protocol": "https",
          "host": [
            "{{environment}}",
            "bond",
            "tech"
          ],
          "path": [
            "api",
            "v0",
            "cards",
            "{{card_id}}",
            "restrictions"
          ]
        }
      },
      "_postman_previewlanguage": "json",
      "header": null,
      "cookie": [
      ],
      "body": ""
    }
  ]
}