Back to Collection Items
-- Important: See this note about string length limitations for strings returned by sp_OAMethod calls.
--
CREATE PROCEDURE ChilkatSample
AS
BEGIN
DECLARE @hr int
-- Important: Do not use nvarchar(max). See the warning about using nvarchar(max).
DECLARE @sTmp0 nvarchar(4000)
-- This example assumes the Chilkat API to have been previously unlocked.
-- See Global Unlock Sample for sample code.
DECLARE @http int
-- Use "Chilkat_9_5_0.Http" for versions of Chilkat < 10.0.0
EXEC @hr = sp_OACreate 'Chilkat.Http', @http OUT
IF @hr <> 0
BEGIN
PRINT 'Failed to create ActiveX component'
RETURN
END
DECLARE @success int
-- Adds the "Authorization: Bearer <access_token>" header.
EXEC sp_OASetProperty @http, 'AuthToken', '<access_token>'
DECLARE @sbResponseBody int
-- Use "Chilkat_9_5_0.StringBuilder" for versions of Chilkat < 10.0.0
EXEC @hr = sp_OACreate 'Chilkat.StringBuilder', @sbResponseBody OUT
EXEC sp_OAMethod @http, 'QuickGetSb', @success OUT, 'https://domain.com/services/data/v{{version}}/ui-api/records/:RECORD_ID', @sbResponseBody
IF @success = 0
BEGIN
EXEC sp_OAGetProperty @http, 'LastErrorText', @sTmp0 OUT
PRINT @sTmp0
EXEC @hr = sp_OADestroy @http
EXEC @hr = sp_OADestroy @sbResponseBody
RETURN
END
DECLARE @jResp int
-- Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0
EXEC @hr = sp_OACreate 'Chilkat.JsonObject', @jResp OUT
EXEC sp_OAMethod @jResp, 'LoadSb', @success OUT, @sbResponseBody
EXEC sp_OASetProperty @jResp, 'EmitCompact', 0
PRINT 'Response Body:'
EXEC sp_OAMethod @jResp, 'Emit', @sTmp0 OUT
PRINT @sTmp0
DECLARE @respStatusCode int
EXEC sp_OAGetProperty @http, 'LastStatus', @respStatusCode OUT
PRINT 'Response Status Code = ' + @respStatusCode
IF @respStatusCode >= 400
BEGIN
PRINT 'Response Header:'
EXEC sp_OAGetProperty @http, 'LastHeader', @sTmp0 OUT
PRINT @sTmp0
PRINT 'Failed.'
EXEC @hr = sp_OADestroy @http
EXEC @hr = sp_OADestroy @sbResponseBody
EXEC @hr = sp_OADestroy @jResp
RETURN
END
-- 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
DECLARE @apiName nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @apiName OUT, 'apiName'
DECLARE @eTag nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @eTag OUT, 'eTag'
DECLARE @DisplayValue nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @DisplayValue OUT, 'fields.Name.displayValue'
DECLARE @Value nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @Value OUT, 'fields.Name.value'
DECLARE @RatingDisplayValue nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @RatingDisplayValue OUT, 'fields.Rating.displayValue'
DECLARE @RatingValue nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @RatingValue OUT, 'fields.Rating.value'
DECLARE @id nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @id OUT, 'id'
DECLARE @lastModifiedById nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @lastModifiedById OUT, 'lastModifiedById'
DECLARE @lastModifiedDate nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @lastModifiedDate OUT, 'lastModifiedDate'
DECLARE @recordTypeId nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @recordTypeId OUT, 'recordTypeId'
DECLARE @recordTypeInfo nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @recordTypeInfo OUT, 'recordTypeInfo'
DECLARE @systemModstamp nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @systemModstamp OUT, 'systemModstamp'
DECLARE @weakEtag int
EXEC sp_OAMethod @jResp, 'IntOf', @weakEtag OUT, 'weakEtag'
EXEC @hr = sp_OADestroy @http
EXEC @hr = sp_OADestroy @sbResponseBody
EXEC @hr = sp_OADestroy @jResp
END
GO
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}"
}
]
}