Back to Collection Items
#include <C_CkHttpW.h>
#include <C_CkJsonObjectW.h>
#include <C_CkHttpResponseW.h>
void ChilkatSample(void)
{
HCkHttpW http;
BOOL success;
HCkJsonObjectW json;
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.
// {
// "partnerId": "{{partner_id}}",
// "name": "{{product_name}}",
// "listingName": "{{product_listing_name}}",
// "tags": {
// "applications": [
// "LO Connect",
// "Encompass Smart Client"
// ],
// "categories": [
// "{{service_category}}"
// ],
// "workflows": [
// "interactive"
// ]
// },
// "integrationType": "ASYNC",
// "interfaceUrl": "{{product_interface_url}}",
// "webhooks": [
// {
// "resource": "urn:elli:epc:transaction",
// "events": [
// "created",
// "updated"
// ],
// "signingkey": "qwertyuiop1234567890!@#$f*()",
// "url": "{{webhook_url}}"
// },
// {
// "resource": "urn:elli:epc:transaction:event",
// "events": [
// "created"
// ],
// "signingkey": "qwertyuiop1234567890!@#$f*()",
// "url": "{{webhook_url}}"
// }
// ],
// "requestTypes": [
// "{{request_type}}"
// ],
// "entitlements": {
// "access": {
// "allow": [
// "urn:elli:encompass:{{encompass_instance_id}}"
// ],
// "deny": [
// ]
// }
// },
// "credential": {
// "required": [
// "username",
// "password"
// ],
// "properties": {
// "username": {
// "type": "String",
// "title": "Username"
// },
// "password": {
// "type": "String",
// "title": "Password",
// "secret": true
// }
// }
// }
// }
json = CkJsonObjectW_Create();
CkJsonObjectW_UpdateString(json,L"partnerId",L"{{partner_id}}");
CkJsonObjectW_UpdateString(json,L"name",L"{{product_name}}");
CkJsonObjectW_UpdateString(json,L"listingName",L"{{product_listing_name}}");
CkJsonObjectW_UpdateString(json,L"tags.applications[0]",L"LO Connect");
CkJsonObjectW_UpdateString(json,L"tags.applications[1]",L"Encompass Smart Client");
CkJsonObjectW_UpdateString(json,L"tags.categories[0]",L"{{service_category}}");
CkJsonObjectW_UpdateString(json,L"tags.workflows[0]",L"interactive");
CkJsonObjectW_UpdateString(json,L"integrationType",L"ASYNC");
CkJsonObjectW_UpdateString(json,L"interfaceUrl",L"{{product_interface_url}}");
CkJsonObjectW_UpdateString(json,L"webhooks[0].resource",L"urn:elli:epc:transaction");
CkJsonObjectW_UpdateString(json,L"webhooks[0].events[0]",L"created");
CkJsonObjectW_UpdateString(json,L"webhooks[0].events[1]",L"updated");
CkJsonObjectW_UpdateString(json,L"webhooks[0].signingkey",L"qwertyuiop1234567890!@#$f*()");
CkJsonObjectW_UpdateString(json,L"webhooks[0].url",L"{{webhook_url}}");
CkJsonObjectW_UpdateString(json,L"webhooks[1].resource",L"urn:elli:epc:transaction:event");
CkJsonObjectW_UpdateString(json,L"webhooks[1].events[0]",L"created");
CkJsonObjectW_UpdateString(json,L"webhooks[1].signingkey",L"qwertyuiop1234567890!@#$f*()");
CkJsonObjectW_UpdateString(json,L"webhooks[1].url",L"{{webhook_url}}");
CkJsonObjectW_UpdateString(json,L"requestTypes[0]",L"{{request_type}}");
CkJsonObjectW_UpdateString(json,L"entitlements.access.allow[0]",L"urn:elli:encompass:{{encompass_instance_id}}");
CkJsonObjectW_UpdateNewArray(json,L"entitlements.access.deny");
CkJsonObjectW_UpdateString(json,L"credential.required[0]",L"username");
CkJsonObjectW_UpdateString(json,L"credential.required[1]",L"password");
CkJsonObjectW_UpdateString(json,L"credential.properties.username.type",L"String");
CkJsonObjectW_UpdateString(json,L"credential.properties.username.title",L"Username");
CkJsonObjectW_UpdateString(json,L"credential.properties.password.type",L"String");
CkJsonObjectW_UpdateString(json,L"credential.properties.password.title",L"Password");
CkJsonObjectW_UpdateBool(json,L"credential.properties.password.secret",TRUE);
// Adds the "Authorization: Bearer {{partner_token}}" header.
CkHttpW_putAuthToken(http,L"{{partner_token}}");
CkHttpW_SetRequestHeader(http,L"Content-Type",L"application/json");
resp = CkHttpW_PostJson3(http,L"https://domain.com/partner/v2/products?view=complete",L"application/json",json);
if (CkHttpW_getLastMethodSuccess(http) == FALSE) {
wprintf(L"%s\n",CkHttpW_lastErrorText(http));
CkHttpW_Dispose(http);
CkJsonObjectW_Dispose(json);
return;
}
wprintf(L"%d\n",CkHttpResponseW_getStatusCode(resp));
wprintf(L"%s\n",CkHttpResponseW_bodyStr(resp));
CkHttpResponseW_Dispose(resp);
CkHttpW_Dispose(http);
CkJsonObjectW_Dispose(json);
}
Curl Command
curl -X POST
-H "Authorization: Bearer {{partner_token}}"
-H "Content-Type: application/json"
-d '{
"partnerId": "{{partner_id}}",
"name": "{{product_name}}",
"listingName": "{{product_listing_name}}",
"tags": {
"applications": [
"LO Connect",
"Encompass Smart Client"
],
"categories": [
"{{service_category}}"
],
"workflows": [
"interactive"
]
},
"integrationType": "ASYNC",
"interfaceUrl": "{{product_interface_url}}",
"webhooks": [
{
"resource": "urn:elli:epc:transaction",
"events": [
"created",
"updated"
],
"signingkey": "qwertyuiop1234567890!@#$%^&*()",
"url": "{{webhook_url}}"
},
{
"resource": "urn:elli:epc:transaction:event",
"events": [
"created"
],
"signingkey": "qwertyuiop1234567890!@#$%^&*()",
"url": "{{webhook_url}}"
}
],
"requestTypes": [
"{{request_type}}"
],
"entitlements": {
"access": {
"allow": [
"urn:elli:encompass:{{encompass_instance_id}}"
],
"deny": []
}
},
"credential": {
"required": [
"username",
"password"
],
"properties": {
"username": {
"type": "String",
"title": "Username"
},
"password": {
"type": "String",
"title": "Password",
"secret": true
}
}
}
}'
https://domain.com/partner/v2/products?view=complete
Postman Collection Item JSON
{
"name": "[Partner] Create a New Product",
"event": [
{
"listen": "test",
"script": {
"type": "text/javascript",
"exec": [
"// Extract Product identifier from response body",
"var jsonData = JSON.parse(responseBody);",
"var productId = jsonData.id;",
"",
"// Set to an environment variable",
"postman.setEnvironmentVariable(\"product_id\", productId);"
]
}
}
],
"_postman_id": "677a22b1-31ae-4dde-a759-f6a27216e2d5",
"request": {
"method": "POST",
"header": [
{
"key": "Authorization",
"type": "text",
"value": "Bearer {{partner_token}}"
},
{
"key": "Content-Type",
"name": "Content-Type",
"value": "application/json",
"type": "text"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"partnerId\": \"{{partner_id}}\",\n \"name\": \"{{product_name}}\",\n \"listingName\": \"{{product_listing_name}}\",\n \"tags\": {\n \"applications\": [\n \"LO Connect\",\n \"Encompass Smart Client\"\n ],\n \"categories\": [\n \"{{service_category}}\"\n ],\n \"workflows\": [\n \"interactive\"\n ]\n },\n \"integrationType\": \"ASYNC\",\n \"interfaceUrl\": \"{{product_interface_url}}\",\n \"webhooks\": [\n {\n \"resource\": \"urn:elli:epc:transaction\",\n \"events\": [\n \"created\",\n \"updated\"\n ],\n \"signingkey\": \"qwertyuiop1234567890!@#$%^&*()\",\n \"url\": \"{{webhook_url}}\"\n },\n {\n \"resource\": \"urn:elli:epc:transaction:event\",\n \"events\": [\n \"created\"\n ],\n \"signingkey\": \"qwertyuiop1234567890!@#$%^&*()\",\n \"url\": \"{{webhook_url}}\"\n }\n ],\n \"requestTypes\": [\n \"{{request_type}}\"\n ],\n \"entitlements\": {\n \"access\": {\n \"allow\": [\n \"urn:elli:encompass:{{encompass_instance_id}}\"\n ],\n \"deny\": []\n }\n },\n \"credential\": {\n \"required\": [\n \"username\",\n \"password\"\n ],\n \"properties\": {\n \"username\": {\n \"type\": \"String\",\n \"title\": \"Username\"\n },\n \"password\": {\n \"type\": \"String\",\n \"title\": \"Password\",\n \"secret\": true\n }\n }\n }\n}"
},
"url": {
"raw": "{{api_host}}/partner/v2/products?view=complete",
"host": [
"{{api_host}}"
],
"path": [
"partner",
"v2",
"products"
],
"query": [
{
"key": "view",
"value": "complete"
}
]
}
},
"response": [
]
}