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.
-- {
-- "data": [
-- {
-- "Owner": {
-- "id": "{{user-id}}"
-- },
-- "Parent_Account": {
-- "id": "{{parent-account-id}}"
-- },
-- "Ownership": "Private",
-- "Description": "Design your own layouts that align your business processes precisely. Assign them to profiles appropriately.",
-- "Account_Type": "Competitor",
-- "Rating": "Active",
-- "SIC_Code": 12792,
-- "Shipping_State": "Shipping_State",
-- "Website": "crm.zoho.com",
-- "Employees": 12792,
-- "Industry": "Data/Telecom OEM",
-- "Account_Site": "Account_Site",
-- "Phone": "988844559",
-- "Billing_Country": "Billing_Country",
-- "Account_Name": "Account_Name",
-- "Account_Number": "1245681",
-- "Ticker_Symbol": "Ticker_Symbol",
-- "Billing_Street": "Billing_Street",
-- "Billing_Code": "Billing_Code",
-- "Shipping_City": "Shipping_City",
-- "Shipping_Country": "Shipping_Country",
-- "Shipping_Code": "Shipping_Code",
-- "Billing_City": "Billing_City",
-- "Billing_State": "Billing_State",
-- "Fax": "Fax",
-- "Annual_Revenue": 127.67,
-- "Shipping_Street": "Shipping_Street"
-- }
-- ]
-- }
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, 'UpdateString', @success OUT, 'data[0].Owner.id', '{{user-id}}'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'data[0].Parent_Account.id', '{{parent-account-id}}'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'data[0].Ownership', 'Private'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'data[0].Description', 'Design your own layouts that align your business processes precisely. Assign them to profiles appropriately.'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'data[0].Account_Type', 'Competitor'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'data[0].Rating', 'Active'
EXEC sp_OAMethod @json, 'UpdateInt', @success OUT, 'data[0].SIC_Code', 12792
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'data[0].Shipping_State', 'Shipping_State'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'data[0].Website', 'crm.zoho.com'
EXEC sp_OAMethod @json, 'UpdateInt', @success OUT, 'data[0].Employees', 12792
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'data[0].Industry', 'Data/Telecom OEM'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'data[0].Account_Site', 'Account_Site'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'data[0].Phone', '988844559'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'data[0].Billing_Country', 'Billing_Country'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'data[0].Account_Name', 'Account_Name'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'data[0].Account_Number', '1245681'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'data[0].Ticker_Symbol', 'Ticker_Symbol'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'data[0].Billing_Street', 'Billing_Street'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'data[0].Billing_Code', 'Billing_Code'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'data[0].Shipping_City', 'Shipping_City'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'data[0].Shipping_Country', 'Shipping_Country'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'data[0].Shipping_Code', 'Shipping_Code'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'data[0].Billing_City', 'Billing_City'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'data[0].Billing_State', 'Billing_State'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'data[0].Fax', 'Fax'
EXEC sp_OAMethod @json, 'UpdateNumber', @success OUT, 'data[0].Annual_Revenue', '127.67'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'data[0].Shipping_Street', 'Shipping_Street'
EXEC sp_OAMethod @http, 'SetRequestHeader', NULL, 'Authorization', '{{authorization-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, 'PUT', 'https://domain.com/crm/v2.1/Accounts/{{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
EXEC sp_OAGetProperty @resp, 'StatusCode', @iTmp0 OUT
PRINT @iTmp0
EXEC sp_OAGetProperty @resp, 'BodyStr', @sTmp0 OUT
PRINT @sTmp0
EXEC @hr = sp_OADestroy @resp
EXEC @hr = sp_OADestroy @http
EXEC @hr = sp_OADestroy @json
EXEC @hr = sp_OADestroy @sbRequestBody
END
GO
Curl Command
curl -X PUT
-H "Authorization: Bearer <access_token>"
-H "Authorization: {{authorization-token}}"
-H "Content-Type: application/json"
-d '{
"data": [
{
"Owner": {
"id": "{{user-id}}"
},
"Parent_Account": {
"id": "{{parent-account-id}}"
},
"Ownership": "Private",
"Description": "Design your own layouts that align your business processes precisely. Assign them to profiles appropriately.",
"Account_Type": "Competitor",
"Rating": "Active",
"SIC_Code": 12792,
"Shipping_State": "Shipping_State",
"Website": "crm.zoho.com",
"Employees": 12792,
"Industry": "Data/Telecom OEM",
"Account_Site": "Account_Site",
"Phone": "988844559",
"Billing_Country": "Billing_Country",
"Account_Name": "Account_Name",
"Account_Number": "1245681",
"Ticker_Symbol": "Ticker_Symbol",
"Billing_Street": "Billing_Street",
"Billing_Code": "Billing_Code",
"Shipping_City": "Shipping_City",
"Shipping_Country": "Shipping_Country",
"Shipping_Code": "Shipping_Code",
"Billing_City": "Billing_City",
"Billing_State": "Billing_State",
"Fax": "Fax",
"Annual_Revenue": 127.67,
"Shipping_Street": "Shipping_Street"
}
]
}'
https://domain.com/crm/v2.1/Accounts/{{record-id}}
Postman Collection Item JSON
{
"name": "Accounts",
"request": {
"method": "PUT",
"header": [
{
"key": "Authorization",
"value": "{{authorization-token}}"
},
{
"key": "Content-Type",
"value": "application/json"
}
],
"body": {
"mode": "raw",
"raw": "{\n\t\"data\": [\n\t\t{\n\t\t\t\"Owner\": {\n\t\t\t\t\"id\": \"{{user-id}}\"\n\t\t\t},\n\t\t\t\"Parent_Account\": {\n\t\t\t\t\"id\": \"{{parent-account-id}}\"\n\t\t\t},\n\t\t\t\"Ownership\": \"Private\",\n\t\t\t\"Description\": \"Design your own layouts that align your business processes precisely. Assign them to profiles appropriately.\",\n\t\t\t\"Account_Type\": \"Competitor\",\n\t\t\t\"Rating\": \"Active\",\n\t\t\t\"SIC_Code\": 12792,\n\t\t\t\"Shipping_State\": \"Shipping_State\",\n\t\t\t\"Website\": \"crm.zoho.com\",\n\t\t\t\"Employees\": 12792,\n\t\t\t\"Industry\": \"Data/Telecom OEM\",\n\t\t\t\"Account_Site\": \"Account_Site\",\n\t\t\t\"Phone\": \"988844559\",\n\t\t\t\"Billing_Country\": \"Billing_Country\",\n\t\t\t\"Account_Name\": \"Account_Name\",\n\t\t\t\"Account_Number\": \"1245681\",\n\t\t\t\"Ticker_Symbol\": \"Ticker_Symbol\",\n\t\t\t\"Billing_Street\": \"Billing_Street\",\n\t\t\t\"Billing_Code\": \"Billing_Code\",\n\t\t\t\"Shipping_City\": \"Shipping_City\",\n\t\t\t\"Shipping_Country\": \"Shipping_Country\",\n\t\t\t\"Shipping_Code\": \"Shipping_Code\",\n\t\t\t\"Billing_City\": \"Billing_City\",\n\t\t\t\"Billing_State\": \"Billing_State\",\n\t\t\t\"Fax\": \"Fax\",\n\t\t\t\"Annual_Revenue\": 127.67,\n\t\t\t\"Shipping_Street\": \"Shipping_Street\"\n\t\t}\n\t]\n}"
},
"url": {
"raw": "{{api-domain}}/crm/v2.1/Accounts/{{record-id}}",
"host": [
"{{api-domain}}"
],
"path": [
"crm",
"v2.1",
"Accounts",
"{{record-id}}"
]
},
"description": "To update existing entities in the module."
},
"response": [
]
}