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
DECLARE @iTmp0 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
-- Use this online tool to generate code from sample JSON: Generate Code to Create JSON
-- The following JSON is sent in the request body.
-- {
-- "allowSaveOnDuplicate": false,
-- "fields": {
-- "FieldAPIName": "FieldValue"
-- }
-- }
DECLARE @json int
-- Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0
EXEC @hr = sp_OACreate 'Chilkat.JsonObject', @json OUT
EXEC sp_OAMethod @json, 'UpdateBool', @success OUT, 'allowSaveOnDuplicate', 0
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'fields.FieldAPIName', 'FieldValue'
-- Adds the "Authorization: Bearer <access_token>" header.
EXEC sp_OASetProperty @http, 'AuthToken', '<access_token>'
EXEC sp_OAMethod @http, 'SetRequestHeader', NULL, 'Content-Type', 'application/json'
DECLARE @sbRequestBody int
-- Use "Chilkat_9_5_0.StringBuilder" for versions of Chilkat < 10.0.0
EXEC @hr = sp_OACreate 'Chilkat.StringBuilder', @sbRequestBody OUT
EXEC sp_OAMethod @json, 'EmitSb', @success OUT, @sbRequestBody
DECLARE @resp int
EXEC sp_OAMethod @http, 'PTextSb', @resp OUT, 'PATCH', 'https://domain.com/services/data/v{{version}}/ui-api/records/:RECORD_ID', @sbRequestBody, 'utf-8', 'application/json', 0, 0
EXEC sp_OAGetProperty @http, 'LastMethodSuccess', @iTmp0 OUT
IF @iTmp0 = 0
BEGIN
EXEC sp_OAGetProperty @http, 'LastErrorText', @sTmp0 OUT
PRINT @sTmp0
EXEC @hr = sp_OADestroy @http
EXEC @hr = sp_OADestroy @json
EXEC @hr = sp_OADestroy @sbRequestBody
RETURN
END
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 @resp, 'GetBodySb', @success OUT, @sbResponseBody
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 @resp, 'StatusCode', @respStatusCode OUT
PRINT 'Response Status Code = ' + @respStatusCode
IF @respStatusCode >= 400
BEGIN
PRINT 'Response Header:'
EXEC sp_OAGetProperty @resp, 'Header', @sTmp0 OUT
PRINT @sTmp0
PRINT 'Failed.'
EXEC @hr = sp_OADestroy @resp
EXEC @hr = sp_OADestroy @http
EXEC @hr = sp_OADestroy @json
EXEC @hr = sp_OADestroy @sbRequestBody
EXEC @hr = sp_OADestroy @sbResponseBody
EXEC @hr = sp_OADestroy @jResp
RETURN
END
EXEC @hr = sp_OADestroy @resp
-- Sample JSON response:
-- (Sample code for parsing the JSON response is shown below)
-- {
-- "apiName": "Account",
-- "childRelationships": {},
-- "eTag": "1be6f040e46732e79a0999d6fea9fe7d",
-- "fields": {
-- "AccountNumber": {
-- "displayValue": null,
-- "value": null
-- },
-- "Active__c": {
-- "displayValue": null,
-- "value": null
-- },
-- "AnnualRevenue": {
-- "displayValue": null,
-- "value": null
-- },
-- "BillingCity": {
-- "displayValue": null,
-- "value": null
-- },
-- "BillingCountry": {
-- "displayValue": null,
-- "value": null
-- },
-- "BillingPostalCode": {
-- "displayValue": null,
-- "value": null
-- },
-- "BillingState": {
-- "displayValue": null,
-- "value": null
-- },
-- "BillingStreet": {
-- "displayValue": null,
-- "value": null
-- },
-- "CreatedBy": {
-- "displayValue": "Philippe Ozil",
-- "value": {
-- "apiName": "User",
-- "childRelationships": {},
-- "eTag": "cc07f7ef1b08ddbd75074c69512dd388",
-- "fields": {
-- "Id": {
-- "displayValue": null,
-- "value": "005B0000003TOI6IAO"
-- },
-- "Name": {
-- "displayValue": null,
-- "value": "Philippe Ozil"
-- }
-- },
-- "id": "005B0000003TOI6IAO",
-- "lastModifiedById": "005B0000003TOI6IAO",
-- "lastModifiedDate": "2023-02-02T10:32:12.000Z",
-- "recordTypeId": null,
-- "recordTypeInfo": null,
-- "systemModstamp": "2023-09-27T15:47:51.000Z",
-- "weakEtag": 1695829671000
-- }
-- },
-- "CreatedById": {
-- "displayValue": null,
-- "value": "005B0000003TOI6IAO"
-- },
-- "CreatedDate": {
-- "displayValue": "27/09/2023 18:01",
-- "value": "2023-09-27T16:01:14.000Z"
-- },
-- "CustomerPriority__c": {
-- "displayValue": null,
-- "value": null
-- },
-- "Description": {
-- "displayValue": null,
-- "value": null
-- },
-- "Fax": {
-- "displayValue": null,
-- "value": null
-- },
-- "Industry": {
-- "displayValue": null,
-- "value": null
-- },
-- "LastModifiedBy": {
-- "displayValue": "Philippe Ozil",
-- "value": {
-- "apiName": "User",
-- "childRelationships": {},
-- "eTag": "cc07f7ef1b08ddbd75074c69512dd388",
-- "fields": {
-- "Id": {
-- "displayValue": null,
-- "value": "005B0000003TOI6IAO"
-- },
-- "Name": {
-- "displayValue": null,
-- "value": "Philippe Ozil"
-- }
-- },
-- "id": "005B0000003TOI6IAO",
-- "lastModifiedById": "005B0000003TOI6IAO",
-- "lastModifiedDate": "2023-02-02T10:32:12.000Z",
-- "recordTypeId": null,
-- "recordTypeInfo": null,
-- "systemModstamp": "2023-09-27T15:47:51.000Z",
-- "weakEtag": 1695829671000
-- }
-- },
-- "LastModifiedById": {
-- "displayValue": null,
-- "value": "005B0000003TOI6IAO"
-- },
-- "LastModifiedDate": {
-- "displayValue": "27/09/2023 18:04",
-- "value": "2023-09-27T16:04:41.000Z"
-- },
-- "Name": {
-- "displayValue": null,
-- "value": "My Renamed Account"
-- },
-- "NumberOfEmployees": {
-- "displayValue": null,
-- "value": null
-- },
-- "NumberofLocations__c": {
-- "displayValue": null,
-- "value": null
-- },
-- "Owner": {
-- "displayValue": "Philippe Ozil",
-- "value": {
-- "apiName": "User",
-- "childRelationships": {},
-- "eTag": "cc07f7ef1b08ddbd75074c69512dd388",
-- "fields": {
-- "Id": {
-- "displayValue": null,
-- "value": "005B0000003TOI6IAO"
-- },
-- "Name": {
-- "displayValue": null,
-- "value": "Philippe Ozil"
-- }
-- },
-- "id": "005B0000003TOI6IAO",
-- "lastModifiedById": "005B0000003TOI6IAO",
-- "lastModifiedDate": "2023-02-02T10:32:12.000Z",
-- "recordTypeId": null,
-- "recordTypeInfo": null,
-- "systemModstamp": "2023-09-27T15:47:51.000Z",
-- "weakEtag": 1695829671000
-- }
-- },
-- "OwnerId": {
-- "displayValue": null,
-- "value": "005B0000003TOI6IAO"
-- },
-- "Ownership": {
-- "displayValue": null,
-- "value": null
-- },
-- "Parent": {
-- "displayValue": null,
-- "value": null
-- },
-- "ParentId": {
-- "displayValue": null,
-- "value": null
-- },
-- "Phone": {
-- "displayValue": null,
-- "value": null
-- },
-- "Rating": {
-- "displayValue": null,
-- "value": null
-- },
-- "SLAExpirationDate__c": {
-- "displayValue": null,
-- "value": null
-- },
-- "SLASerialNumber__c": {
-- "displayValue": null,
-- "value": null
-- },
-- "SLA__c": {
-- "displayValue": null,
-- "value": null
-- },
-- "ShippingCity": {
-- "displayValue": null,
-- "value": null
-- },
-- "ShippingCountry": {
-- "displayValue": null,
-- "value": null
-- },
-- "ShippingPostalCode": {
-- "displayValue": null,
-- "value": null
-- },
-- "ShippingState": {
-- "displayValue": null,
-- "value": null
-- },
-- "ShippingStreet": {
-- "displayValue": null,
-- "value": null
-- },
-- "Sic": {
-- "displayValue": null,
-- "value": null
-- },
-- "Site": {
-- "displayValue": null,
-- "value": null
-- },
-- "TickerSymbol": {
-- "displayValue": null,
-- "value": null
-- },
-- "Type": {
-- "displayValue": null,
-- "value": null
-- },
-- "UpsellOpportunity__c": {
-- "displayValue": null,
-- "value": null
-- },
-- "Website": {
-- "displayValue": null,
-- "value": null
-- }
-- },
-- "id": "0011Q00002Z2P5jQAF",
-- "lastModifiedById": "005B0000003TOI6IAO",
-- "lastModifiedDate": "2023-09-27T16:04:41.000Z",
-- "recordTypeId": "012000000000000AAA",
-- "recordTypeInfo": null,
-- "systemModstamp": "2023-09-27T16:04:41.000Z",
-- "weakEtag": 1695830681000
-- }
-- 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.AccountNumber.displayValue'
DECLARE @Value nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @Value OUT, 'fields.AccountNumber.value'
DECLARE @Active__cDisplayValue nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @Active__cDisplayValue OUT, 'fields.Active__c.displayValue'
DECLARE @Active__cValue nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @Active__cValue OUT, 'fields.Active__c.value'
DECLARE @AnnualRevenueDisplayValue nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @AnnualRevenueDisplayValue OUT, 'fields.AnnualRevenue.displayValue'
DECLARE @AnnualRevenueValue nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @AnnualRevenueValue OUT, 'fields.AnnualRevenue.value'
DECLARE @BillingCityDisplayValue nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @BillingCityDisplayValue OUT, 'fields.BillingCity.displayValue'
DECLARE @BillingCityValue nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @BillingCityValue OUT, 'fields.BillingCity.value'
DECLARE @BillingCountryDisplayValue nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @BillingCountryDisplayValue OUT, 'fields.BillingCountry.displayValue'
DECLARE @BillingCountryValue nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @BillingCountryValue OUT, 'fields.BillingCountry.value'
DECLARE @BillingPostalCodeDisplayValue nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @BillingPostalCodeDisplayValue OUT, 'fields.BillingPostalCode.displayValue'
DECLARE @BillingPostalCodeValue nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @BillingPostalCodeValue OUT, 'fields.BillingPostalCode.value'
DECLARE @BillingStateDisplayValue nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @BillingStateDisplayValue OUT, 'fields.BillingState.displayValue'
DECLARE @BillingStateValue nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @BillingStateValue OUT, 'fields.BillingState.value'
DECLARE @BillingStreetDisplayValue nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @BillingStreetDisplayValue OUT, 'fields.BillingStreet.displayValue'
DECLARE @BillingStreetValue nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @BillingStreetValue OUT, 'fields.BillingStreet.value'
DECLARE @CreatedByDisplayValue nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @CreatedByDisplayValue OUT, 'fields.CreatedBy.displayValue'
DECLARE @ApiName nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @ApiName OUT, 'fields.CreatedBy.value.apiName'
DECLARE @ETag nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @ETag OUT, 'fields.CreatedBy.value.eTag'
DECLARE @IdDisplayValue nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @IdDisplayValue OUT, 'fields.CreatedBy.value.fields.Id.displayValue'
DECLARE @IdValue nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @IdValue OUT, 'fields.CreatedBy.value.fields.Id.value'
DECLARE @NameDisplayValue nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @NameDisplayValue OUT, 'fields.CreatedBy.value.fields.Name.displayValue'
DECLARE @NameValue nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @NameValue OUT, 'fields.CreatedBy.value.fields.Name.value'
DECLARE @Id nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @Id OUT, 'fields.CreatedBy.value.id'
DECLARE @LastModifiedById nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @LastModifiedById OUT, 'fields.CreatedBy.value.lastModifiedById'
DECLARE @LastModifiedDate nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @LastModifiedDate OUT, 'fields.CreatedBy.value.lastModifiedDate'
DECLARE @RecordTypeId nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @RecordTypeId OUT, 'fields.CreatedBy.value.recordTypeId'
DECLARE @RecordTypeInfo nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @RecordTypeInfo OUT, 'fields.CreatedBy.value.recordTypeInfo'
DECLARE @SystemModstamp nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @SystemModstamp OUT, 'fields.CreatedBy.value.systemModstamp'
DECLARE @WeakEtag int
EXEC sp_OAMethod @jResp, 'IntOf', @WeakEtag OUT, 'fields.CreatedBy.value.weakEtag'
DECLARE @CreatedByIdDisplayValue nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @CreatedByIdDisplayValue OUT, 'fields.CreatedById.displayValue'
DECLARE @CreatedByIdValue nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @CreatedByIdValue OUT, 'fields.CreatedById.value'
DECLARE @CreatedDateDisplayValue nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @CreatedDateDisplayValue OUT, 'fields.CreatedDate.displayValue'
DECLARE @CreatedDateValue nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @CreatedDateValue OUT, 'fields.CreatedDate.value'
DECLARE @CustomerPriority__cDisplayValue nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @CustomerPriority__cDisplayValue OUT, 'fields.CustomerPriority__c.displayValue'
DECLARE @CustomerPriority__cValue nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @CustomerPriority__cValue OUT, 'fields.CustomerPriority__c.value'
DECLARE @DescriptionDisplayValue nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @DescriptionDisplayValue OUT, 'fields.Description.displayValue'
DECLARE @DescriptionValue nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @DescriptionValue OUT, 'fields.Description.value'
DECLARE @FaxDisplayValue nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @FaxDisplayValue OUT, 'fields.Fax.displayValue'
DECLARE @FaxValue nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @FaxValue OUT, 'fields.Fax.value'
DECLARE @IndustryDisplayValue nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @IndustryDisplayValue OUT, 'fields.Industry.displayValue'
DECLARE @IndustryValue nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @IndustryValue OUT, 'fields.Industry.value'
DECLARE @LastModifiedByDisplayValue nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @LastModifiedByDisplayValue OUT, 'fields.LastModifiedBy.displayValue'
DECLARE @ValueApiName nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @ValueApiName OUT, 'fields.LastModifiedBy.value.apiName'
DECLARE @ValueETag nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @ValueETag OUT, 'fields.LastModifiedBy.value.eTag'
EXEC sp_OAMethod @jResp, 'StringOf', @IdDisplayValue OUT, 'fields.LastModifiedBy.value.fields.Id.displayValue'
EXEC sp_OAMethod @jResp, 'StringOf', @IdValue OUT, 'fields.LastModifiedBy.value.fields.Id.value'
EXEC sp_OAMethod @jResp, 'StringOf', @NameDisplayValue OUT, 'fields.LastModifiedBy.value.fields.Name.displayValue'
EXEC sp_OAMethod @jResp, 'StringOf', @NameValue OUT, 'fields.LastModifiedBy.value.fields.Name.value'
DECLARE @ValueId nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @ValueId OUT, 'fields.LastModifiedBy.value.id'
DECLARE @ValueLastModifiedById nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @ValueLastModifiedById OUT, 'fields.LastModifiedBy.value.lastModifiedById'
DECLARE @ValueLastModifiedDate nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @ValueLastModifiedDate OUT, 'fields.LastModifiedBy.value.lastModifiedDate'
DECLARE @ValueRecordTypeId nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @ValueRecordTypeId OUT, 'fields.LastModifiedBy.value.recordTypeId'
DECLARE @ValueRecordTypeInfo nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @ValueRecordTypeInfo OUT, 'fields.LastModifiedBy.value.recordTypeInfo'
DECLARE @ValueSystemModstamp nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @ValueSystemModstamp OUT, 'fields.LastModifiedBy.value.systemModstamp'
DECLARE @ValueWeakEtag int
EXEC sp_OAMethod @jResp, 'IntOf', @ValueWeakEtag OUT, 'fields.LastModifiedBy.value.weakEtag'
DECLARE @LastModifiedByIdDisplayValue nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @LastModifiedByIdDisplayValue OUT, 'fields.LastModifiedById.displayValue'
DECLARE @LastModifiedByIdValue nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @LastModifiedByIdValue OUT, 'fields.LastModifiedById.value'
DECLARE @LastModifiedDateDisplayValue nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @LastModifiedDateDisplayValue OUT, 'fields.LastModifiedDate.displayValue'
DECLARE @LastModifiedDateValue nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @LastModifiedDateValue OUT, 'fields.LastModifiedDate.value'
EXEC sp_OAMethod @jResp, 'StringOf', @NameDisplayValue OUT, 'fields.Name.displayValue'
EXEC sp_OAMethod @jResp, 'StringOf', @NameValue OUT, 'fields.Name.value'
DECLARE @NumberOfEmployeesDisplayValue nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @NumberOfEmployeesDisplayValue OUT, 'fields.NumberOfEmployees.displayValue'
DECLARE @NumberOfEmployeesValue nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @NumberOfEmployeesValue OUT, 'fields.NumberOfEmployees.value'
DECLARE @NumberofLocations__cDisplayValue nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @NumberofLocations__cDisplayValue OUT, 'fields.NumberofLocations__c.displayValue'
DECLARE @NumberofLocations__cValue nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @NumberofLocations__cValue OUT, 'fields.NumberofLocations__c.value'
DECLARE @OwnerDisplayValue nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @OwnerDisplayValue OUT, 'fields.Owner.displayValue'
EXEC sp_OAMethod @jResp, 'StringOf', @ValueApiName OUT, 'fields.Owner.value.apiName'
EXEC sp_OAMethod @jResp, 'StringOf', @ValueETag OUT, 'fields.Owner.value.eTag'
EXEC sp_OAMethod @jResp, 'StringOf', @IdDisplayValue OUT, 'fields.Owner.value.fields.Id.displayValue'
EXEC sp_OAMethod @jResp, 'StringOf', @IdValue OUT, 'fields.Owner.value.fields.Id.value'
EXEC sp_OAMethod @jResp, 'StringOf', @NameDisplayValue OUT, 'fields.Owner.value.fields.Name.displayValue'
EXEC sp_OAMethod @jResp, 'StringOf', @NameValue OUT, 'fields.Owner.value.fields.Name.value'
EXEC sp_OAMethod @jResp, 'StringOf', @ValueId OUT, 'fields.Owner.value.id'
EXEC sp_OAMethod @jResp, 'StringOf', @ValueLastModifiedById OUT, 'fields.Owner.value.lastModifiedById'
EXEC sp_OAMethod @jResp, 'StringOf', @ValueLastModifiedDate OUT, 'fields.Owner.value.lastModifiedDate'
EXEC sp_OAMethod @jResp, 'StringOf', @ValueRecordTypeId OUT, 'fields.Owner.value.recordTypeId'
EXEC sp_OAMethod @jResp, 'StringOf', @ValueRecordTypeInfo OUT, 'fields.Owner.value.recordTypeInfo'
EXEC sp_OAMethod @jResp, 'StringOf', @ValueSystemModstamp OUT, 'fields.Owner.value.systemModstamp'
EXEC sp_OAMethod @jResp, 'IntOf', @ValueWeakEtag OUT, 'fields.Owner.value.weakEtag'
DECLARE @OwnerIdDisplayValue nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @OwnerIdDisplayValue OUT, 'fields.OwnerId.displayValue'
DECLARE @OwnerIdValue nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @OwnerIdValue OUT, 'fields.OwnerId.value'
DECLARE @OwnershipDisplayValue nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @OwnershipDisplayValue OUT, 'fields.Ownership.displayValue'
DECLARE @OwnershipValue nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @OwnershipValue OUT, 'fields.Ownership.value'
DECLARE @ParentDisplayValue nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @ParentDisplayValue OUT, 'fields.Parent.displayValue'
DECLARE @ParentValue nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @ParentValue OUT, 'fields.Parent.value'
DECLARE @ParentIdDisplayValue nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @ParentIdDisplayValue OUT, 'fields.ParentId.displayValue'
DECLARE @ParentIdValue nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @ParentIdValue OUT, 'fields.ParentId.value'
DECLARE @PhoneDisplayValue nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @PhoneDisplayValue OUT, 'fields.Phone.displayValue'
DECLARE @PhoneValue nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @PhoneValue OUT, 'fields.Phone.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 @SLAExpirationDate__cDisplayValue nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @SLAExpirationDate__cDisplayValue OUT, 'fields.SLAExpirationDate__c.displayValue'
DECLARE @SLAExpirationDate__cValue nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @SLAExpirationDate__cValue OUT, 'fields.SLAExpirationDate__c.value'
DECLARE @SLASerialNumber__cDisplayValue nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @SLASerialNumber__cDisplayValue OUT, 'fields.SLASerialNumber__c.displayValue'
DECLARE @SLASerialNumber__cValue nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @SLASerialNumber__cValue OUT, 'fields.SLASerialNumber__c.value'
DECLARE @SLA__cDisplayValue nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @SLA__cDisplayValue OUT, 'fields.SLA__c.displayValue'
DECLARE @SLA__cValue nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @SLA__cValue OUT, 'fields.SLA__c.value'
DECLARE @ShippingCityDisplayValue nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @ShippingCityDisplayValue OUT, 'fields.ShippingCity.displayValue'
DECLARE @ShippingCityValue nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @ShippingCityValue OUT, 'fields.ShippingCity.value'
DECLARE @ShippingCountryDisplayValue nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @ShippingCountryDisplayValue OUT, 'fields.ShippingCountry.displayValue'
DECLARE @ShippingCountryValue nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @ShippingCountryValue OUT, 'fields.ShippingCountry.value'
DECLARE @ShippingPostalCodeDisplayValue nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @ShippingPostalCodeDisplayValue OUT, 'fields.ShippingPostalCode.displayValue'
DECLARE @ShippingPostalCodeValue nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @ShippingPostalCodeValue OUT, 'fields.ShippingPostalCode.value'
DECLARE @ShippingStateDisplayValue nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @ShippingStateDisplayValue OUT, 'fields.ShippingState.displayValue'
DECLARE @ShippingStateValue nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @ShippingStateValue OUT, 'fields.ShippingState.value'
DECLARE @ShippingStreetDisplayValue nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @ShippingStreetDisplayValue OUT, 'fields.ShippingStreet.displayValue'
DECLARE @ShippingStreetValue nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @ShippingStreetValue OUT, 'fields.ShippingStreet.value'
DECLARE @SicDisplayValue nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @SicDisplayValue OUT, 'fields.Sic.displayValue'
DECLARE @SicValue nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @SicValue OUT, 'fields.Sic.value'
DECLARE @SiteDisplayValue nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @SiteDisplayValue OUT, 'fields.Site.displayValue'
DECLARE @SiteValue nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @SiteValue OUT, 'fields.Site.value'
DECLARE @TickerSymbolDisplayValue nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @TickerSymbolDisplayValue OUT, 'fields.TickerSymbol.displayValue'
DECLARE @TickerSymbolValue nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @TickerSymbolValue OUT, 'fields.TickerSymbol.value'
DECLARE @TypeDisplayValue nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @TypeDisplayValue OUT, 'fields.Type.displayValue'
DECLARE @TypeValue nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @TypeValue OUT, 'fields.Type.value'
DECLARE @UpsellOpportunity__cDisplayValue nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @UpsellOpportunity__cDisplayValue OUT, 'fields.UpsellOpportunity__c.displayValue'
DECLARE @UpsellOpportunity__cValue nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @UpsellOpportunity__cValue OUT, 'fields.UpsellOpportunity__c.value'
DECLARE @WebsiteDisplayValue nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @WebsiteDisplayValue OUT, 'fields.Website.displayValue'
DECLARE @WebsiteValue nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @WebsiteValue OUT, 'fields.Website.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 @json
EXEC @hr = sp_OADestroy @sbRequestBody
EXEC @hr = sp_OADestroy @sbResponseBody
EXEC @hr = sp_OADestroy @jResp
END
GO
Curl Command
curl -X PATCH
-H "Authorization: Bearer <access_token>"
-H "Content-Type: application/json"
-d '{
"allowSaveOnDuplicate": false,
"fields": {
"FieldAPIName": "FieldValue"
}
}'
https://domain.com/services/data/v{{version}}/ui-api/records/:RECORD_ID
Postman Collection Item JSON
{
"name": "Update a Record",
"event": [
{
"listen": "prerequest",
"script": {
"exec": [
""
],
"type": "text/javascript"
}
}
],
"request": {
"method": "PATCH",
"header": [
{
"key": "Content-Type",
"type": "text",
"value": "application/json"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"allowSaveOnDuplicate\": false,\n \"fields\": {\n \"FieldAPIName\": \"FieldValue\"\n }\n}"
},
"url": {
"raw": "{{_endpoint}}/services/data/v{{version}}/ui-api/records/:RECORD_ID",
"host": [
"{{_endpoint}}"
],
"path": [
"services",
"data",
"v{{version}}",
"ui-api",
"records",
":RECORD_ID"
],
"variable": [
{
"key": "RECORD_ID",
"value": "",
"description": "Record ID"
}
]
},
"description": "Update a record's data.\nUser Interface API enforces Salesforce validation rules. If a validation rule fails, the response is an Error with Output.\n\nWhen you make a PATCH request to update a record, make sure that the record hasn’t changed since the user started editing it. To find out whether it’s safe to save a record, pass the If-Modified-Since HTTP header in the request.\n\nAs of API version 43.0, if you pass read-only fields in a request body, the response is an Error with Output."
},
"response": [
{
"name": "Update a Record",
"originalRequest": {
"method": "PATCH",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"allowSaveOnDuplicate\": false,\n \"fields\": {\n \"Name\": \"My Renamed Account\"\n }\n}"
},
"url": {
"raw": "{{_endpoint}}/services/data/v{{version}}/ui-api/records/:RECORD_ID",
"host": [
"{{_endpoint}}"
],
"path": [
"services",
"data",
"v{{version}}",
"ui-api",
"records",
":RECORD_ID"
],
"variable": [
{
"key": "RECORD_ID",
"value": "0011Q00002Z2P5jQAF",
"description": "Record ID"
}
]
}
},
"status": "OK",
"code": 200,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Date",
"value": "Wed, 27 Sep 2023 16:04:41 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": "\"1be6f040e46732e79a0999d6fea9fe7d\""
},
{
"key": "Content-Type",
"value": "application/json;charset=UTF-8"
},
{
"key": "Transfer-Encoding",
"value": "chunked"
}
],
"cookie": [
],
"body": "{\n \"apiName\": \"Account\",\n \"childRelationships\": {},\n \"eTag\": \"1be6f040e46732e79a0999d6fea9fe7d\",\n \"fields\": {\n \"AccountNumber\": {\n \"displayValue\": null,\n \"value\": null\n },\n \"Active__c\": {\n \"displayValue\": null,\n \"value\": null\n },\n \"AnnualRevenue\": {\n \"displayValue\": null,\n \"value\": null\n },\n \"BillingCity\": {\n \"displayValue\": null,\n \"value\": null\n },\n \"BillingCountry\": {\n \"displayValue\": null,\n \"value\": null\n },\n \"BillingPostalCode\": {\n \"displayValue\": null,\n \"value\": null\n },\n \"BillingState\": {\n \"displayValue\": null,\n \"value\": null\n },\n \"BillingStreet\": {\n \"displayValue\": null,\n \"value\": null\n },\n \"CreatedBy\": {\n \"displayValue\": \"Philippe Ozil\",\n \"value\": {\n \"apiName\": \"User\",\n \"childRelationships\": {},\n \"eTag\": \"cc07f7ef1b08ddbd75074c69512dd388\",\n \"fields\": {\n \"Id\": {\n \"displayValue\": null,\n \"value\": \"005B0000003TOI6IAO\"\n },\n \"Name\": {\n \"displayValue\": null,\n \"value\": \"Philippe Ozil\"\n }\n },\n \"id\": \"005B0000003TOI6IAO\",\n \"lastModifiedById\": \"005B0000003TOI6IAO\",\n \"lastModifiedDate\": \"2023-02-02T10:32:12.000Z\",\n \"recordTypeId\": null,\n \"recordTypeInfo\": null,\n \"systemModstamp\": \"2023-09-27T15:47:51.000Z\",\n \"weakEtag\": 1695829671000\n }\n },\n \"CreatedById\": {\n \"displayValue\": null,\n \"value\": \"005B0000003TOI6IAO\"\n },\n \"CreatedDate\": {\n \"displayValue\": \"27/09/2023 18:01\",\n \"value\": \"2023-09-27T16:01:14.000Z\"\n },\n \"CustomerPriority__c\": {\n \"displayValue\": null,\n \"value\": null\n },\n \"Description\": {\n \"displayValue\": null,\n \"value\": null\n },\n \"Fax\": {\n \"displayValue\": null,\n \"value\": null\n },\n \"Industry\": {\n \"displayValue\": null,\n \"value\": null\n },\n \"LastModifiedBy\": {\n \"displayValue\": \"Philippe Ozil\",\n \"value\": {\n \"apiName\": \"User\",\n \"childRelationships\": {},\n \"eTag\": \"cc07f7ef1b08ddbd75074c69512dd388\",\n \"fields\": {\n \"Id\": {\n \"displayValue\": null,\n \"value\": \"005B0000003TOI6IAO\"\n },\n \"Name\": {\n \"displayValue\": null,\n \"value\": \"Philippe Ozil\"\n }\n },\n \"id\": \"005B0000003TOI6IAO\",\n \"lastModifiedById\": \"005B0000003TOI6IAO\",\n \"lastModifiedDate\": \"2023-02-02T10:32:12.000Z\",\n \"recordTypeId\": null,\n \"recordTypeInfo\": null,\n \"systemModstamp\": \"2023-09-27T15:47:51.000Z\",\n \"weakEtag\": 1695829671000\n }\n },\n \"LastModifiedById\": {\n \"displayValue\": null,\n \"value\": \"005B0000003TOI6IAO\"\n },\n \"LastModifiedDate\": {\n \"displayValue\": \"27/09/2023 18:04\",\n \"value\": \"2023-09-27T16:04:41.000Z\"\n },\n \"Name\": {\n \"displayValue\": null,\n \"value\": \"My Renamed Account\"\n },\n \"NumberOfEmployees\": {\n \"displayValue\": null,\n \"value\": null\n },\n \"NumberofLocations__c\": {\n \"displayValue\": null,\n \"value\": null\n },\n \"Owner\": {\n \"displayValue\": \"Philippe Ozil\",\n \"value\": {\n \"apiName\": \"User\",\n \"childRelationships\": {},\n \"eTag\": \"cc07f7ef1b08ddbd75074c69512dd388\",\n \"fields\": {\n \"Id\": {\n \"displayValue\": null,\n \"value\": \"005B0000003TOI6IAO\"\n },\n \"Name\": {\n \"displayValue\": null,\n \"value\": \"Philippe Ozil\"\n }\n },\n \"id\": \"005B0000003TOI6IAO\",\n \"lastModifiedById\": \"005B0000003TOI6IAO\",\n \"lastModifiedDate\": \"2023-02-02T10:32:12.000Z\",\n \"recordTypeId\": null,\n \"recordTypeInfo\": null,\n \"systemModstamp\": \"2023-09-27T15:47:51.000Z\",\n \"weakEtag\": 1695829671000\n }\n },\n \"OwnerId\": {\n \"displayValue\": null,\n \"value\": \"005B0000003TOI6IAO\"\n },\n \"Ownership\": {\n \"displayValue\": null,\n \"value\": null\n },\n \"Parent\": {\n \"displayValue\": null,\n \"value\": null\n },\n \"ParentId\": {\n \"displayValue\": null,\n \"value\": null\n },\n \"Phone\": {\n \"displayValue\": null,\n \"value\": null\n },\n \"Rating\": {\n \"displayValue\": null,\n \"value\": null\n },\n \"SLAExpirationDate__c\": {\n \"displayValue\": null,\n \"value\": null\n },\n \"SLASerialNumber__c\": {\n \"displayValue\": null,\n \"value\": null\n },\n \"SLA__c\": {\n \"displayValue\": null,\n \"value\": null\n },\n \"ShippingCity\": {\n \"displayValue\": null,\n \"value\": null\n },\n \"ShippingCountry\": {\n \"displayValue\": null,\n \"value\": null\n },\n \"ShippingPostalCode\": {\n \"displayValue\": null,\n \"value\": null\n },\n \"ShippingState\": {\n \"displayValue\": null,\n \"value\": null\n },\n \"ShippingStreet\": {\n \"displayValue\": null,\n \"value\": null\n },\n \"Sic\": {\n \"displayValue\": null,\n \"value\": null\n },\n \"Site\": {\n \"displayValue\": null,\n \"value\": null\n },\n \"TickerSymbol\": {\n \"displayValue\": null,\n \"value\": null\n },\n \"Type\": {\n \"displayValue\": null,\n \"value\": null\n },\n \"UpsellOpportunity__c\": {\n \"displayValue\": null,\n \"value\": null\n },\n \"Website\": {\n \"displayValue\": null,\n \"value\": null\n }\n },\n \"id\": \"0011Q00002Z2P5jQAF\",\n \"lastModifiedById\": \"005B0000003TOI6IAO\",\n \"lastModifiedDate\": \"2023-09-27T16:04:41.000Z\",\n \"recordTypeId\": \"012000000000000AAA\",\n \"recordTypeInfo\": null,\n \"systemModstamp\": \"2023-09-27T16:04:41.000Z\",\n \"weakEtag\": 1695830681000\n}"
}
]
}