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 XML: Generate Code to Create XML
    -- The following XML is sent in the request body.
    -- <?xml version="1.0" encoding="utf-8"?>
    -- <lookup-value>
    --     <id>4</id>
    --     <active>false</active>
    -- </lookup-value>
    -- 
    DECLARE @xml int
    EXEC @hr = sp_OACreate 'Chilkat.Xml', @xml OUT
    EXEC sp_OASetProperty @xml, 'Tag', 'lookup-value'
    EXEC sp_OAMethod @xml, 'UpdateChildContentInt', NULL, 'id', 4
    EXEC sp_OAMethod @xml, 'UpdateChildContent', NULL, 'active', 'false'
    -- Adds the "Authorization: Bearer <access_token>" header.
    EXEC sp_OASetProperty @http, 'AuthToken', '<access_token>'
    DECLARE @sbRequestBody int
    EXEC @hr = sp_OACreate 'Chilkat.StringBuilder', @sbRequestBody OUT
    EXEC sp_OAMethod @xml, 'GetXmlSb', @success OUT, @sbRequestBody
    DECLARE @resp int
    EXEC @hr = sp_OACreate 'Chilkat.HttpResponse', @resp OUT
    EXEC sp_OAMethod @http, 'HttpSb', @success OUT, 'PUT', '["id","name","active",{"custom_fields":{}}]}]},{"lookup":["id","name","active"]},{"custom_fields":{}}]', @sbRequestBody, 'utf-8', 'application/xml', @resp
    IF @success = 0
      BEGIN
        EXEC sp_OAGetProperty @http, 'LastErrorText', @sTmp0 OUT
        PRINT @sTmp0
        EXEC @hr = sp_OADestroy @http
        EXEC @hr = sp_OADestroy @xml
        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 @xml
    EXEC @hr = sp_OADestroy @sbRequestBody
    EXEC @hr = sp_OADestroy @resp
END
GO
        Curl Command
        curl -X PUT
	-H "Authorization: Bearer <access_token>"
	-d '<lookup-value>
    <id>4</id>
    <active>false</active>
</lookup-value>'
https://domain.com/lookup_values/:id?fields=["id","name","external-ref-num","external-ref-code","active",{"parent":["id","name","active",{"custom_fields":{}},{"parent": ["id","name","active",{"custom_fields":{}}]}]},{"lookup":["id","name","active"]},{"custom_fields":{}}]
        Postman Collection Item JSON
        {
  "name": "Update Existing Lookup Value",
  "request": {
    "method": "PUT",
    "header": [
    ],
    "body": {
      "mode": "raw",
      "raw": "<lookup-value>\n    <id>4</id>\n    <active>false</active>\n</lookup-value>",
      "options": {
        "raw": {
          "language": "xml"
        }
      }
    },
    "url": {
      "raw": "{{URL}}/lookup_values/:id?fields=[\"id\",\"name\",\"external-ref-num\",\"external-ref-code\",\"active\",{\"parent\":[\"id\",\"name\",\"active\",{\"custom_fields\":{}},{\"parent\": [\"id\",\"name\",\"active\",{\"custom_fields\":{}}]}]},{\"lookup\":[\"id\",\"name\",\"active\"]},{\"custom_fields\":{}}]",
      "host": [
        "{{URL}}"
      ],
      "path": [
        "lookup_values",
        ":id"
      ],
      "query": [
        {
          "key": "fields",
          "value": "[\"id\",\"name\",\"external-ref-num\",\"external-ref-code\",\"active\",{\"parent\":[\"id\",\"name\",\"active\",{\"custom_fields\":{}},{\"parent\": [\"id\",\"name\",\"active\",{\"custom_fields\":{}}]}]},{\"lookup\":[\"id\",\"name\",\"active\"]},{\"custom_fields\":{}}]"
        }
      ],
      "variable": [
        {
          "key": "id",
          "value": "4"
        }
      ]
    }
  },
  "response": [
  ]
}