Chilkat Online Tools

delphiDll / EPC 2.0 - Partner Sandbox - 19.4 November [External] / [Partner] Send Acknowledgment Response

Back to Collection Items

var
http: HCkHttp;
success: Boolean;
json: HCkJsonObject;
sbRequestBody: HCkStringBuilder;
resp: HCkHttpResponse;

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

http := CkHttp_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.

// {
//   "status": "processing",
//   "partnerStatus": "Order Accepted",
//   "referenceNumber": "ORDER_REFERENCE_NUMBER",
//   "respondingParty ": {
//     "name": "COMPANY_NAME",
//     "address": "COMPANY_STREET_ADDRESS",
//     "city": "COMPANY_CITY",
//     "state": "COMPANY_STATE",
//     "postalCode": "COMPANY_ZIP_CODE",
//     "pointOfContact": {
//       "name": "CONTACT_NAME",
//       "role": "CONTACT_ROLE",
//       "phone": "CONTACT_PHONE_NUMBER",
//       "email": "CONTACT_EMAIL"
//     }
//   }
// }

json := CkJsonObject_Create();
CkJsonObject_UpdateString(json,'status','processing');
CkJsonObject_UpdateString(json,'partnerStatus','Order Accepted');
CkJsonObject_UpdateString(json,'referenceNumber','ORDER_REFERENCE_NUMBER');
CkJsonObject_UpdateString(json,'"respondingParty ".name','COMPANY_NAME');
CkJsonObject_UpdateString(json,'"respondingParty ".address','COMPANY_STREET_ADDRESS');
CkJsonObject_UpdateString(json,'"respondingParty ".city','COMPANY_CITY');
CkJsonObject_UpdateString(json,'"respondingParty ".state','COMPANY_STATE');
CkJsonObject_UpdateString(json,'"respondingParty ".postalCode','COMPANY_ZIP_CODE');
CkJsonObject_UpdateString(json,'"respondingParty ".pointOfContact.name','CONTACT_NAME');
CkJsonObject_UpdateString(json,'"respondingParty ".pointOfContact.role','CONTACT_ROLE');
CkJsonObject_UpdateString(json,'"respondingParty ".pointOfContact.phone','CONTACT_PHONE_NUMBER');
CkJsonObject_UpdateString(json,'"respondingParty ".pointOfContact.email','CONTACT_EMAIL');

// Adds the "Authorization: Bearer {{partner_token}}" header.
CkHttp_putAuthToken(http,'{{partner_token}}');
CkHttp_SetRequestHeader(http,'Content-Type','application/json');

sbRequestBody := CkStringBuilder_Create();
CkJsonObject_EmitSb(json,sbRequestBody);

resp := CkHttp_PTextSb(http,'PATCH','https://domain.com/',sbRequestBody,'utf-8','application/json',False,False);
if (CkHttp_getLastMethodSuccess(http) = False) then
  begin
    Memo1.Lines.Add(CkHttp__lastErrorText(http));
    Exit;
  end;

Memo1.Lines.Add(IntToStr(CkHttpResponse_getStatusCode(resp)));
Memo1.Lines.Add(CkHttpResponse__bodyStr(resp));
CkHttpResponse_Dispose(resp);

CkHttp_Dispose(http);
CkJsonObject_Dispose(json);
CkStringBuilder_Dispose(sbRequestBody);

Curl Command

curl -X PATCH
	-H "Authorization: Bearer {{partner_token}}"
	-H "Content-Type: application/json"
	-d '{
    "status": "processing",
    "partnerStatus": "Order Accepted",
    "referenceNumber": "ORDER_REFERENCE_NUMBER",
    "respondingParty ": {
        "name": "COMPANY_NAME",
        "address": "COMPANY_STREET_ADDRESS",
        "city": "COMPANY_CITY",
        "state": "COMPANY_STATE",
        "postalCode": "COMPANY_ZIP_CODE",
        "pointOfContact": {
            "name": "CONTACT_NAME",
            "role": "CONTACT_ROLE",
            "phone": "CONTACT_PHONE_NUMBER",
            "email": "CONTACT_EMAIL"
        }
    }
}'
https://domain.com/

Postman Collection Item JSON

{
  "name": "[Partner] Send Acknowledgment Response",
  "_postman_id": "1165b237-e991-481e-bd7b-f05d17b2de2f",
  "request": {
    "method": "PATCH",
    "header": [
      {
        "key": "Authorization",
        "value": "Bearer {{partner_token}}",
        "type": "text"
      },
      {
        "key": "Content-Type",
        "name": "Content-Type",
        "value": "application/json",
        "type": "text"
      }
    ],
    "body": {
      "mode": "raw",
      "raw": "{\n    \"status\": \"processing\",\n    \"partnerStatus\": \"Order Accepted\",\n    \"referenceNumber\": \"ORDER_REFERENCE_NUMBER\",\n    \"respondingParty \": {\n        \"name\": \"COMPANY_NAME\",\n        \"address\": \"COMPANY_STREET_ADDRESS\",\n        \"city\": \"COMPANY_CITY\",\n        \"state\": \"COMPANY_STATE\",\n        \"postalCode\": \"COMPANY_ZIP_CODE\",\n        \"pointOfContact\": {\n            \"name\": \"CONTACT_NAME\",\n            \"role\": \"CONTACT_ROLE\",\n            \"phone\": \"CONTACT_PHONE_NUMBER\",\n            \"email\": \"CONTACT_EMAIL\"\n        }\n    }\n}"
    },
    "url": "{{api_host}}/partner/v2/transactions/{{transaction_id}}/response"
  },
  "response": [
  ]
}