Back to Collection Items
#include <C_CkHttp.h>
#include <C_CkJsonObject.h>
#include <C_CkHttpResponse.h>
void ChilkatSample(void)
{
HCkHttp http;
BOOL success;
HCkJsonObject json;
HCkHttpResponse resp;
// 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.
// {
// "productContexts": [
// {
// "product2Id": "{{ClassTrainingProduct}}",
// "productSellingModelId": "{{OneTimePSM}}"
// },
// {
// "product2Id": "{{VirtualRouterProduct}}"
// }
// ],
// "fields": [
// "id",
// "name",
// "IsActive",
// "ProductCode"
// ],
// "retrievalType": "ExcludeChildComponents"
// }
json = CkJsonObject_Create();
CkJsonObject_UpdateString(json,"productContexts[0].product2Id","{{ClassTrainingProduct}}");
CkJsonObject_UpdateString(json,"productContexts[0].productSellingModelId","{{OneTimePSM}}");
CkJsonObject_UpdateString(json,"productContexts[1].product2Id","{{VirtualRouterProduct}}");
CkJsonObject_UpdateString(json,"fields[0]","id");
CkJsonObject_UpdateString(json,"fields[1]","name");
CkJsonObject_UpdateString(json,"fields[2]","IsActive");
CkJsonObject_UpdateString(json,"fields[3]","ProductCode");
CkJsonObject_UpdateString(json,"retrievalType","ExcludeChildComponents");
// Adds the "Authorization: Bearer <access_token>" header.
CkHttp_putAuthToken(http,"<access_token>");
CkHttp_SetRequestHeader(http,"Content-Type","application/json");
resp = CkHttp_PostJson3(http,"https://domain.com/services/data/v{{version}}/commerce/catalog-products/actions/get-products","application/json",json);
if (CkHttp_getLastMethodSuccess(http) == FALSE) {
printf("%s\n",CkHttp_lastErrorText(http));
CkHttp_Dispose(http);
CkJsonObject_Dispose(json);
return;
}
printf("%d\n",CkHttpResponse_getStatusCode(resp));
printf("%s\n",CkHttpResponse_bodyStr(resp));
CkHttpResponse_Dispose(resp);
CkHttp_Dispose(http);
CkJsonObject_Dispose(json);
}
Curl Command
curl -X POST
-H "Authorization: Bearer <access_token>"
-H "Content-Type: application/json"
-d '{
"productContexts": [
{
"product2Id": "{{ClassTrainingProduct}}",
"productSellingModelId": "{{OneTimePSM}}"
},
{
"product2Id": "{{VirtualRouterProduct}}"
}
],
"fields": [
"id",
"name",
"IsActive",
"ProductCode"
],
"retrievalType": "ExcludeChildComponents"
}'
https://domain.com/services/data/v{{version}}/commerce/catalog-products/actions/get-products
Postman Collection Item JSON
{
"name": "Request Product Information (No Bundles)",
"request": {
"method": "POST",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"productContexts\": [\n {\n \"product2Id\": \"{{ClassTrainingProduct}}\",\n \"productSellingModelId\": \"{{OneTimePSM}}\"\n },\n {\n \"product2Id\": \"{{VirtualRouterProduct}}\" \n }\n ],\n \"fields\": [\n \"id\",\n \"name\",\n \"IsActive\",\n \"ProductCode\"\n ],\n \"retrievalType\": \"ExcludeChildComponents\"\n}"
},
"url": {
"raw": "{{_endpoint}}/services/data/v{{version}}/commerce/catalog-products/actions/get-products",
"host": [
"{{_endpoint}}"
],
"path": [
"services",
"data",
"v{{version}}",
"commerce",
"catalog-products",
"actions",
"get-products"
]
},
"description": "Request information for two products that aren't bundles. For the first product, request only the information about the specified product selling model. For the second product, request information about all related product selling models.\n\nSee [Request Product Information](https://desktop.postman.com/?desktopVersion=10.13.6&webVersion=10.13.7-ui-230522-1730&userId=10709048&teamId=0)."
},
"response": [
]
}