Chilkat Online Tools

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

Back to Collection Items

#import <CkoHttp.h>
#import <CkoJsonObject.h>
#import <CkoStringBuilder.h>
#import <CkoHttpResponse.h>

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

CkoHttp *http = [[CkoHttp alloc] init];
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.

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

CkoJsonObject *json = [[CkoJsonObject alloc] init];
[json UpdateString: @"status" value: @"processing"];
[json UpdateString: @"partnerStatus" value: @"Order Accepted"];
[json UpdateString: @"referenceNumber" value: @"ORDER_REFERENCE_NUMBER"];
[json UpdateString: @"\"respondingParty \".name" value: @"COMPANY_NAME"];
[json UpdateString: @"\"respondingParty \".address" value: @"COMPANY_STREET_ADDRESS"];
[json UpdateString: @"\"respondingParty \".city" value: @"COMPANY_CITY"];
[json UpdateString: @"\"respondingParty \".state" value: @"COMPANY_STATE"];
[json UpdateString: @"\"respondingParty \".postalCode" value: @"COMPANY_ZIP_CODE"];
[json UpdateString: @"\"respondingParty \".pointOfContact.name" value: @"CONTACT_NAME"];
[json UpdateString: @"\"respondingParty \".pointOfContact.role" value: @"CONTACT_ROLE"];
[json UpdateString: @"\"respondingParty \".pointOfContact.phone" value: @"CONTACT_PHONE_NUMBER"];
[json UpdateString: @"\"respondingParty \".pointOfContact.email" value: @"CONTACT_EMAIL"];

// Adds the "Authorization: Bearer {{partner_token}}" header.
http.AuthToken = @"{{partner_token}}";
[http SetRequestHeader: @"Content-Type" value: @"application/json"];

CkoStringBuilder *sbRequestBody = [[CkoStringBuilder alloc] init];
[json EmitSb: sbRequestBody];

CkoHttpResponse *resp = [http PTextSb: @"PATCH" url: @"https://domain.com/" textData: sbRequestBody charset: @"utf-8" contentType: @"application/json" md5: NO gzip: NO];
if (http.LastMethodSuccess == NO) {
    NSLog(@"%@",http.LastErrorText);
    return;
}

NSLog(@"%d",[resp.StatusCode intValue]);
NSLog(@"%@",resp.BodyStr);

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