Back to Collection Items
#include <CkHttp.h>
#include <CkStringBuilder.h>
#include <CkJsonObject.h>
void ChilkatSample(void)
{
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
CkHttp http;
bool success;
// Adds the "Authorization: Bearer <access_token>" header.
http.put_AuthToken("<access_token>");
CkStringBuilder sbResponseBody;
success = http.QuickGetSb("https://domain.com/services/data/v{{version}}/ui-api/records/:RECORD_ID",sbResponseBody);
if (success == false) {
std::cout << http.lastErrorText() << "\r\n";
return;
}
CkJsonObject jResp;
jResp.LoadSb(sbResponseBody);
jResp.put_EmitCompact(false);
std::cout << "Response Body:" << "\r\n";
std::cout << jResp.emit() << "\r\n";
int respStatusCode = http.get_LastStatus();
std::cout << "Response Status Code = " << respStatusCode << "\r\n";
if (respStatusCode >= 400) {
std::cout << "Response Header:" << "\r\n";
std::cout << http.lastHeader() << "\r\n";
std::cout << "Failed." << "\r\n";
return;
}
// Sample JSON response:
// (Sample code for parsing the JSON response is shown below)
// {
// "apiName": "Account",
// "childRelationships": {},
// "eTag": "8897eb60da3dea171b0d755821bf2c36",
// "fields": {
// "Name": {
// "displayValue": null,
// "value": "Burlington Textiles Corp of America"
// },
// "Rating": {
// "displayValue": "Warm",
// "value": "Warm"
// }
// },
// "id": "001B000000UnQ2wIAF",
// "lastModifiedById": "005B0000003TOI6IAO",
// "lastModifiedDate": "2017-08-18T14:46:22.000Z",
// "recordTypeId": "012000000000000AAA",
// "recordTypeInfo": null,
// "systemModstamp": "2017-08-18T14:46:22.000Z",
// "weakEtag": 1503067582000
// }
// Sample code for parsing the JSON response...
// Use this online tool to generate parsing code from sample JSON: Generate JSON Parsing Code
// Chilkat functions returning "const char *" return a pointer to temporary internal memory owned and managed by Chilkat.
const char *apiName = jResp.stringOf("apiName");
const char *eTag = jResp.stringOf("eTag");
const char *DisplayValue = jResp.stringOf("fields.Name.displayValue");
const char *Value = jResp.stringOf("fields.Name.value");
const char *RatingDisplayValue = jResp.stringOf("fields.Rating.displayValue");
const char *RatingValue = jResp.stringOf("fields.Rating.value");
const char *id = jResp.stringOf("id");
const char *lastModifiedById = jResp.stringOf("lastModifiedById");
const char *lastModifiedDate = jResp.stringOf("lastModifiedDate");
const char *recordTypeId = jResp.stringOf("recordTypeId");
const char *recordTypeInfo = jResp.stringOf("recordTypeInfo");
const char *systemModstamp = jResp.stringOf("systemModstamp");
int weakEtag = jResp.IntOf("weakEtag");
}
Curl Command
curl -X GET
-H "Authorization: Bearer <access_token>"
https://domain.com/services/data/v{{version}}/ui-api/records/:RECORD_ID
Postman Collection Item JSON
{
"name": "Get a Record",
"request": {
"method": "GET",
"header": [
],
"url": {
"raw": "{{_endpoint}}/services/data/v{{version}}/ui-api/records/:RECORD_ID",
"host": [
"{{_endpoint}}"
],
"path": [
"services",
"data",
"v{{version}}",
"ui-api",
"records",
":RECORD_ID"
],
"query": [
{
"key": "childRelationships",
"value": "",
"description": "A collection of child relationship names. The records with those child relationship names are included in the response. Specify names in the format ObjectApiName.ChildRelationshipName or ObjectApiName.ChildRelationshipName.FieldApiName. For example, to specify the Contacts relationship on an Account, use Account.Contacts. You can get child relationships one level deep.\nTo get a relationship name, look in the Object Info response body.",
"disabled": true
},
{
"key": "fields",
"value": "",
"description": "Specifies the fields to return. If this property is specified, the response is a union of fields and optionalFields.\nIf the context user doesn’t have access to a field, an error is returned.\n\nIf you’re not sure whether the context user has access to a field and you don’t want the request to fail if they don’t, use the optionalFields parameter.\n\nSpecify names in the format ObjectApiName.FieldName. You can get any field that has a named relationship to this record. There is no limit to the number of fields you can specify.",
"disabled": true
},
{
"key": "layoutTypes",
"value": "",
"description": "Specifies the fields to return. If this property is specified, the response is a union of layoutTypes, modes, and optionalFields.\nA collection containing any of these values:\nCompact—Use this value to get a layout that contains a record’s key fields.\nFull—(Default) Use this value to get a full layout.",
"disabled": true
},
{
"key": "modes",
"value": "",
"description": "The access mode for the record. This value determines which fields to get from a layout. Layouts have different fields for create, edit, and view modes. For example, formula fields are rendered in view mode, but not in create mode because they’re calculated at run time, like formulas in a spreadsheet. A collection containing any of these values:\nCreate—Use this mode if you intend to build UI that lets a user create a record. This mode is used by the /ui-api/record-defaults/create/<SOBJECT_API_NAME> resource.\nEdit—Use this mode if you intend to build UI that lets a user edit a record. This mode is used by the /ui-api/record-defaults/clone/<RECORD_ID> resource.\nView—(Default) Use this mode if you intend to build UI that displays a record.",
"disabled": true
},
{
"key": "optionalFields",
"value": "",
"description": "A collection of optional field names. If a field is accessible to the context user, it’s included in the response. If a field isn’t accessible to the context user, it isn’t included in the response, but it doesn’t cause an error.\nSpecify names in the format ObjectApiName.FieldName. You can get any field that has a named relationship to this record. There is no limit to the number of fields you can specify.",
"disabled": true
},
{
"key": "pageSize",
"value": "",
"description": "The maximum number of child records to return on a page. The default value is 5.",
"disabled": true
},
{
"key": "updateMru",
"value": "",
"description": "To add to the most recently used (MRU) list view, set to true. The default value is false.",
"disabled": true
}
],
"variable": [
{
"key": "RECORD_ID",
"value": ""
}
]
},
"description": "Get a record’s data."
},
"response": [
{
"name": "Get a Record",
"originalRequest": {
"method": "GET",
"header": [
],
"url": {
"raw": "{{_endpoint}}/services/data/v{{version}}/ui-api/records/:RECORD_ID?fields=Account.Name,Account.Rating",
"host": [
"{{_endpoint}}"
],
"path": [
"services",
"data",
"v{{version}}",
"ui-api",
"records",
":RECORD_ID"
],
"query": [
{
"key": "childRelationships",
"value": "",
"description": "A collection of child relationship names. The records with those child relationship names are included in the response. Specify names in the format ObjectApiName.ChildRelationshipName or ObjectApiName.ChildRelationshipName.FieldApiName. For example, to specify the Contacts relationship on an Account, use Account.Contacts. You can get child relationships one level deep.\nTo get a relationship name, look in the Object Info response body.",
"disabled": true
},
{
"key": "fields",
"value": "Account.Name,Account.Rating",
"description": "Specifies the fields to return. If this property is specified, the response is a union of fields and optionalFields.\nIf the context user doesn’t have access to a field, an error is returned.\n\nIf you’re not sure whether the context user has access to a field and you don’t want the request to fail if they don’t, use the optionalFields parameter.\n\nSpecify names in the format ObjectApiName.FieldName. You can get any field that has a named relationship to this record. There is no limit to the number of fields you can specify."
},
{
"key": "layoutTypes",
"value": "",
"description": "Specifies the fields to return. If this property is specified, the response is a union of layoutTypes, modes, and optionalFields.\nA collection containing any of these values:\nCompact—Use this value to get a layout that contains a record’s key fields.\nFull—(Default) Use this value to get a full layout.",
"disabled": true
},
{
"key": "modes",
"value": "",
"description": "The access mode for the record. This value determines which fields to get from a layout. Layouts have different fields for create, edit, and view modes. For example, formula fields are rendered in view mode, but not in create mode because they’re calculated at run time, like formulas in a spreadsheet. A collection containing any of these values:\nCreate—Use this mode if you intend to build UI that lets a user create a record. This mode is used by the /ui-api/record-defaults/create/<SOBJECT_API_NAME> resource.\nEdit—Use this mode if you intend to build UI that lets a user edit a record. This mode is used by the /ui-api/record-defaults/clone/<RECORD_ID> resource.\nView—(Default) Use this mode if you intend to build UI that displays a record.",
"disabled": true
},
{
"key": "optionalFields",
"value": "",
"description": "A collection of optional field names. If a field is accessible to the context user, it’s included in the response. If a field isn’t accessible to the context user, it isn’t included in the response, but it doesn’t cause an error.\nSpecify names in the format ObjectApiName.FieldName. You can get any field that has a named relationship to this record. There is no limit to the number of fields you can specify.",
"disabled": true
},
{
"key": "pageSize",
"value": "",
"description": "The maximum number of child records to return on a page. The default value is 5.",
"disabled": true
},
{
"key": "updateMru",
"value": "",
"description": "To add to the most recently used (MRU) list view, set to true. The default value is false.",
"disabled": true
}
],
"variable": [
{
"key": "RECORD_ID",
"value": "001B000000UnQ2wIAF",
"description": "Record ID"
}
]
}
},
"status": "OK",
"code": 200,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Date",
"value": "Wed, 27 Sep 2023 15:58:57 GMT"
},
{
"key": "Strict-Transport-Security",
"value": "max-age=63072000; includeSubDomains"
},
{
"key": "X-Content-Type-Options",
"value": "nosniff"
},
{
"key": "X-XSS-Protection",
"value": "1; mode=block"
},
{
"key": "X-Robots-Tag",
"value": "none"
},
{
"key": "Cache-Control",
"value": "no-cache,must-revalidate,max-age=0,no-store,private"
},
{
"key": "ETag",
"value": "\"8897eb60da3dea171b0d755821bf2c36--gzip\""
},
{
"key": "Content-Type",
"value": "application/json;charset=UTF-8"
},
{
"key": "Vary",
"value": "Accept-Encoding"
},
{
"key": "Content-Encoding",
"value": "gzip"
},
{
"key": "Transfer-Encoding",
"value": "chunked"
}
],
"cookie": [
],
"body": "{\n \"apiName\": \"Account\",\n \"childRelationships\": {},\n \"eTag\": \"8897eb60da3dea171b0d755821bf2c36\",\n \"fields\": {\n \"Name\": {\n \"displayValue\": null,\n \"value\": \"Burlington Textiles Corp of America\"\n },\n \"Rating\": {\n \"displayValue\": \"Warm\",\n \"value\": \"Warm\"\n }\n },\n \"id\": \"001B000000UnQ2wIAF\",\n \"lastModifiedById\": \"005B0000003TOI6IAO\",\n \"lastModifiedDate\": \"2017-08-18T14:46:22.000Z\",\n \"recordTypeId\": \"012000000000000AAA\",\n \"recordTypeInfo\": null,\n \"systemModstamp\": \"2017-08-18T14:46:22.000Z\",\n \"weakEtag\": 1503067582000\n}"
}
]
}