Back to Collection Items
-- Important: See this note about string length limitations for strings returned by sp_OAMethod calls.
--
CREATE PROCEDURE ChilkatSample
AS
BEGIN
DECLARE @hr int
DECLARE @iTmp0 int
-- Important: Do not use nvarchar(max). See the warning about using nvarchar(max).
DECLARE @sTmp0 nvarchar(4000)
-- This example assumes the Chilkat API to have been previously unlocked.
-- See Global Unlock Sample for sample code.
DECLARE @http int
-- Use "Chilkat_9_5_0.Http" for versions of Chilkat < 10.0.0
EXEC @hr = sp_OACreate 'Chilkat.Http', @http OUT
IF @hr <> 0
BEGIN
PRINT 'Failed to create ActiveX component'
RETURN
END
DECLARE @success int
-- 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"
-- }
-- }
-- }
DECLARE @json int
-- Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0
EXEC @hr = sp_OACreate 'Chilkat.JsonObject', @json OUT
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'status', 'processing'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'partnerStatus', 'Order Accepted'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'referenceNumber', 'ORDER_REFERENCE_NUMBER'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, '"respondingParty ".name', 'COMPANY_NAME'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, '"respondingParty ".address', 'COMPANY_STREET_ADDRESS'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, '"respondingParty ".city', 'COMPANY_CITY'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, '"respondingParty ".state', 'COMPANY_STATE'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, '"respondingParty ".postalCode', 'COMPANY_ZIP_CODE'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, '"respondingParty ".pointOfContact.name', 'CONTACT_NAME'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, '"respondingParty ".pointOfContact.role', 'CONTACT_ROLE'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, '"respondingParty ".pointOfContact.phone', 'CONTACT_PHONE_NUMBER'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, '"respondingParty ".pointOfContact.email', 'CONTACT_EMAIL'
-- Adds the "Authorization: Bearer {{partner_token}}" header.
EXEC sp_OASetProperty @http, 'AuthToken', '{{partner_token}}'
EXEC sp_OAMethod @http, 'SetRequestHeader', NULL, 'Content-Type', 'application/json'
DECLARE @sbRequestBody int
-- Use "Chilkat_9_5_0.StringBuilder" for versions of Chilkat < 10.0.0
EXEC @hr = sp_OACreate 'Chilkat.StringBuilder', @sbRequestBody OUT
EXEC sp_OAMethod @json, 'EmitSb', @success OUT, @sbRequestBody
DECLARE @resp int
EXEC sp_OAMethod @http, 'PTextSb', @resp OUT, 'PATCH', 'https://domain.com/', @sbRequestBody, 'utf-8', 'application/json', 0, 0
EXEC sp_OAGetProperty @http, 'LastMethodSuccess', @iTmp0 OUT
IF @iTmp0 = 0
BEGIN
EXEC sp_OAGetProperty @http, 'LastErrorText', @sTmp0 OUT
PRINT @sTmp0
EXEC @hr = sp_OADestroy @http
EXEC @hr = sp_OADestroy @json
EXEC @hr = sp_OADestroy @sbRequestBody
RETURN
END
EXEC sp_OAGetProperty @resp, 'StatusCode', @iTmp0 OUT
PRINT @iTmp0
EXEC sp_OAGetProperty @resp, 'BodyStr', @sTmp0 OUT
PRINT @sTmp0
EXEC @hr = sp_OADestroy @resp
EXEC @hr = sp_OADestroy @http
EXEC @hr = sp_OADestroy @json
EXEC @hr = sp_OADestroy @sbRequestBody
END
GO
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": [
]
}