Chilkat Online Tools

unicodeCpp / CardPointe API Integration / Void (Retref)

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.

    // {
    //   "merchid": "{{merchid}}",
    //   "retref": "{{retref}}"
    // }

    CkJsonObjectW json;
    json.UpdateString(L"merchid",L"{{merchid}}");
    json.UpdateString(L"retref",L"{{retref}}");

    http.SetRequestHeader(L"Authorization",L"Basic dGVzdGluZzp0ZXN0aW5nMTIz");
    http.SetRequestHeader(L"Content-Type",L"application/json");

    CkStringBuilderW sbRequestBody;
    json.EmitSb(sbRequestBody);

    CkHttpResponseW *resp = http.PTextSb(L"PUT",L"https://domain.com/void",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 PUT
	-H "Authorization: Basic dGVzdGluZzp0ZXN0aW5nMTIz"
	-H "Content-Type: application/json"
	-d '{
    "merchid": "{{merchid}}",
    "retref": "{{retref}}"
}'
https://domain.com/void

Postman Collection Item JSON

{
  "name": "Void (Retref)",
  "request": {
    "method": "PUT",
    "header": [
      {
        "key": "Authorization",
        "value": "Basic dGVzdGluZzp0ZXN0aW5nMTIz"
      },
      {
        "key": "Content-Type",
        "value": "application/json"
      }
    ],
    "body": {
      "mode": "raw",
      "raw": "{\n    \"merchid\": \"{{merchid}}\",\n    \"retref\": \"{{retref}}\"\n}"
    },
    "url": {
      "raw": "{{url}}/void",
      "host": [
        "{{url}}"
      ],
      "path": [
        "void"
      ]
    },
    "description": "[Void Documentation](https://developer.cardconnect.com/cardconnect-api#void)"
  },
  "response": [
  ]
}