Back to Collection Items
#include <CkHttpW.h>
#include <CkJsonObjectW.h>
#include <CkStringBuilderW.h>
#include <CkHttpResponseW.h>
void ChilkatSample(void)
{
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
CkHttpW http;
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.
// {
// "documentTypeCodeName": "creditupdated",
// "namePrimaryLang": "CreditEn",
// "nameSecondaryLang": "CreditAr",
// "descriptionPrimaryLang": "Des-creditEn",
// "descriptionSecondaryLang": "Des-creditAr",
// "activeFrom": "2020-06-09T07:38:54.836Z"
// }
CkJsonObjectW json;
json.UpdateString(L"documentTypeCodeName",L"creditupdated");
json.UpdateString(L"namePrimaryLang",L"CreditEn");
json.UpdateString(L"nameSecondaryLang",L"CreditAr");
json.UpdateString(L"descriptionPrimaryLang",L"Des-creditEn");
json.UpdateString(L"descriptionSecondaryLang",L"Des-creditAr");
json.UpdateString(L"activeFrom",L"2020-06-09T07:38:54.836Z");
// Adds the "Authorization: Bearer <access_token>" header.
http.put_AuthToken(L"<access_token>");
http.SetRequestHeader(L"Accept-Language",L"ar");
CkStringBuilderW sbRequestBody;
json.EmitSb(sbRequestBody);
CkHttpResponseW *resp = http.PTextSb(L"GET",L"https://domain.com/api/v1/documenttypes",sbRequestBody,L"utf-8",L"application/json",false,false);
if (http.get_LastMethodSuccess() == false) {
wprintf(L"%s\n",http.lastErrorText());
return;
}
wprintf(L"%d\n",resp->get_StatusCode());
wprintf(L"%s\n",resp->bodyStr());
delete resp;
}
Curl Command
curl -X GET
-H "Authorization: Bearer <access_token>"
-H "Accept-Language: ar"
-d '{
"documentTypeCodeName": "creditupdated",
"namePrimaryLang": "CreditEn",
"nameSecondaryLang": "CreditAr",
"descriptionPrimaryLang": "Des-creditEn",
"descriptionSecondaryLang": "Des-creditAr",
"activeFrom": "2020-06-09T07:38:54.836Z"
}'
https://domain.com/api/v1/documenttypes
Postman Collection Item JSON
{
"name": "2. Get Document Types",
"protocolProfileBehavior": {
"disableBodyPruning": true
},
"request": {
"auth": {
"type": "bearer",
"bearer": [
{
"key": "token",
"value": "{{generatedAccessToken}}",
"type": "string"
}
]
},
"method": "GET",
"header": [
{
"key": "Accept-Language",
"value": "ar",
"type": "text"
}
],
"body": {
"mode": "raw",
"raw": "{\r\n \"documentTypeCodeName\": \"creditupdated\",\r\n \"namePrimaryLang\": \"CreditEn\",\r\n \"nameSecondaryLang\": \"CreditAr\",\r\n \"descriptionPrimaryLang\": \"Des-creditEn\",\r\n \"descriptionSecondaryLang\": \"Des-creditAr\",\r\n \"activeFrom\": \"2020-06-09T07:38:54.836Z\"\r\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "{{apiBaseUrl}}/api/v1/documenttypes",
"host": [
"{{apiBaseUrl}}"
],
"path": [
"api",
"v1",
"documenttypes"
]
}
},
"response": [
]
}