Back to Collection Items
#include <C_CkHttp.h>
#include <C_CkJsonObject.h>
#include <C_CkHttpResponse.h>
void ChilkatSample(void)
{
HCkHttp http;
BOOL success;
HCkJsonObject queryParams;
HCkHttpResponse resp;
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
http = CkHttp_Create();
queryParams = CkJsonObject_Create();
CkJsonObject_UpdateString(queryParams,"q","Select Name, Id from Product2 Where NAME IN ('SLA_Bronze', 'Classroom Training', 'Virtual Router', 'Work Anywhere Software Bundle') order by Name ASC");
// Adds the "Authorization: Bearer <access_token>" header.
CkHttp_putAuthToken(http,"<access_token>");
resp = CkHttp_QuickRequestParams(http,"GET","https://domain.com/services/data/v{{version}}/query",queryParams);
if (CkHttp_getLastMethodSuccess(http) == FALSE) {
printf("%s\n",CkHttp_lastErrorText(http));
CkHttp_Dispose(http);
CkJsonObject_Dispose(queryParams);
return;
}
printf("%d\n",CkHttpResponse_getStatusCode(resp));
printf("%s\n",CkHttpResponse_bodyStr(resp));
CkHttpResponse_Dispose(resp);
CkHttp_Dispose(http);
CkJsonObject_Dispose(queryParams);
}
Curl Command
curl -G -d "q=Select%20Name,%20Id%20from%20Product2%20Where%20NAME%20IN%20%28%27SLA_Bronze%27,%20%27Classroom%20Training%27,%20%27Virtual%20Router%27,%20%27Work%20Anywhere%20Software%20Bundle%27%29%20order%20by%20Name%20ASC"
-H "Authorization: Bearer <access_token>"
https://domain.com/services/data/v{{version}}/query
Postman Collection Item JSON
{
"name": "Get Products",
"event": [
{
"listen": "test",
"script": {
"exec": [
"const context = pm.environment.name ? pm.environment : pm.collectionVariables;",
"const jsonData = JSON.parse(responseBody);",
"",
"context.set(\"ClassTrainingProduct\", jsonData.records[0].Id);",
"context.set(\"SLA_BronzeProduct\", jsonData.records[1].Id);",
"context.set(\"VirtualRouterProduct\", jsonData.records[2].Id);",
"context.set(\"WorkAnywhereBundleProduct\", jsonData.records[3].Id);",
""
],
"type": "text/javascript"
}
}
],
"protocolProfileBehavior": {
"disableBodyPruning": true
},
"request": {
"method": "GET",
"header": [
],
"body": {
"mode": "raw",
"raw": "",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "{{_endpoint}}/services/data/v{{version}}/query?q=Select Name, Id from Product2 Where NAME IN ('SLA_Bronze', 'Classroom Training', 'Virtual Router', 'Work Anywhere Software Bundle') order by Name ASC",
"host": [
"{{_endpoint}}"
],
"path": [
"services",
"data",
"v{{version}}",
"query"
],
"query": [
{
"key": "q",
"value": "Select Name, Id from Product2 Where NAME IN ('SLA_Bronze', 'Classroom Training', 'Virtual Router', 'Work Anywhere Software Bundle') order by Name ASC"
}
]
}
},
"response": [
]
}