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
    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}}"
    --       },
    --       "Product_Name": {
    --         "id": "{{product-id}}"
    --       },
    --       "Status": "Duplicate",
    --       "Answer": "Design your own layouts that align your business processes precisely. Assign them to profiles appropriately.",
    --       "Solution_Title": "Solution_Title",
    --       "Question": "Design your own layouts that align your business processes precisely. Assign them to profiles appropriately."
    --     }
    --   ]
    -- }
    DECLARE @json int
    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].Product_Name.id', '{{product-id}}'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'data[0].Status', 'Duplicate'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'data[0].Answer', 'Design your own layouts that align your business processes precisely. Assign them to profiles appropriately.'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'data[0].Solution_Title', 'Solution_Title'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'data[0].Question', 'Design your own layouts that align your business processes precisely. Assign them to profiles appropriately.'
    EXEC sp_OAMethod @http, 'SetRequestHeader', NULL, 'Authorization', '{{authorization-token}}'
    EXEC sp_OAMethod @http, 'SetRequestHeader', NULL, 'Content-Type', 'application/json'
    DECLARE @sbRequestBody int
    EXEC @hr = sp_OACreate 'Chilkat.StringBuilder', @sbRequestBody OUT
    EXEC sp_OAMethod @json, 'EmitSb', @success OUT, @sbRequestBody
    DECLARE @resp int
    EXEC @hr = sp_OACreate 'Chilkat.HttpResponse', @resp OUT
    EXEC sp_OAMethod @http, 'HttpSb', @success OUT, 'PUT', 'https://domain.com/crm/v2/Solutions/{{record-id}}', @sbRequestBody, 'utf-8', 'application/json', @resp
    IF @success = 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
        EXEC @hr = sp_OADestroy @resp
        RETURN
      END
    EXEC sp_OAGetProperty @resp, 'StatusCode', @iTmp0 OUT
    PRINT @iTmp0
    EXEC sp_OAGetProperty @resp, 'BodyStr', @sTmp0 OUT
    PRINT @sTmp0
    EXEC @hr = sp_OADestroy @http
    EXEC @hr = sp_OADestroy @json
    EXEC @hr = sp_OADestroy @sbRequestBody
    EXEC @hr = sp_OADestroy @resp
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}}"
			},
			"Product_Name": {
				"id": "{{product-id}}"
			},
			"Status": "Duplicate",
			"Answer": "Design your own layouts that align your business processes precisely. Assign them to profiles appropriately.",
			"Solution_Title": "Solution_Title",
			"Question": "Design your own layouts that align your business processes precisely. Assign them to profiles appropriately."
		}
	]
}'
https://domain.com/crm/v2/Solutions/{{record-id}}
        Postman Collection Item JSON
        {
  "name": "Solutions",
  "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\"Product_Name\": {\n\t\t\t\t\"id\": \"{{product-id}}\"\n\t\t\t},\n\t\t\t\"Status\": \"Duplicate\",\n\t\t\t\"Answer\": \"Design your own layouts that align your business processes precisely. Assign them to profiles appropriately.\",\n\t\t\t\"Solution_Title\": \"Solution_Title\",\n\t\t\t\"Question\": \"Design your own layouts that align your business processes precisely. Assign them to profiles appropriately.\"\n\t\t}\n\t]\n}"
    },
    "url": {
      "raw": "{{api-domain}}/crm/v2/Solutions/{{record-id}}",
      "host": [
        "{{api-domain}}"
      ],
      "path": [
        "crm",
        "v2",
        "Solutions",
        "{{record-id}}"
      ]
    },
    "description": "To update existing entities in the module."
  },
  "response": [
  ]
}