Chilkat Online Tools

SQL Server / DocuSign REST API / Update Consumer Disclosure.

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_9_5_0.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.

    -- {
    --   "companyName": "sample string 1",
    --   "companyPhone": "sample string 2",
    --   "withdrawEmail": "sample string 3",
    --   "withdrawByEmail": "sample string 4",
    --   "withdrawByPhone": "sample string 5",
    --   "withdrawByMail": "sample string 6",
    --   "withdrawAddressLine1": "sample string 7",
    --   "withdrawAddressLine2": "sample string 8",
    --   "withdrawCity": "sample string 9",
    --   "withdrawState": "sample string 10",
    --   "withdrawPostalCode": "sample string 11",
    --   "withdrawConsequences": "sample string 12",
    --   "withdrawOther": "sample string 13",
    --   "withdrawPhone": "sample string 14",
    --   "changeEmail": "sample string 15",
    --   "changeEmailOther": "sample string 16",
    --   "copyCostPerPage": "sample string 17",
    --   "copyRequestEmail": "sample string 18",
    --   "copyFeeCollectionMethod": "sample string 19",
    --   "custom": "sample string 20",
    --   "pdfId": "sample string 21",
    --   "enableEsign": "sample string 22",
    --   "useBrand": "sample string 23",
    --   "esignAgreement": "sample string 24",
    --   "esignText": "sample string 25",
    --   "allowCDWithdraw": "sample string 26",
    --   "mustAgreeToEsign": "sample string 27",
    --   "useConsumerDisclosureWithinAccount": "sample string 28"
    -- }

    DECLARE @json int
    EXEC @hr = sp_OACreate 'Chilkat_9_5_0.JsonObject', @json OUT

    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'companyName', 'sample string 1'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'companyPhone', 'sample string 2'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'withdrawEmail', 'sample string 3'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'withdrawByEmail', 'sample string 4'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'withdrawByPhone', 'sample string 5'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'withdrawByMail', 'sample string 6'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'withdrawAddressLine1', 'sample string 7'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'withdrawAddressLine2', 'sample string 8'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'withdrawCity', 'sample string 9'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'withdrawState', 'sample string 10'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'withdrawPostalCode', 'sample string 11'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'withdrawConsequences', 'sample string 12'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'withdrawOther', 'sample string 13'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'withdrawPhone', 'sample string 14'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'changeEmail', 'sample string 15'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'changeEmailOther', 'sample string 16'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'copyCostPerPage', 'sample string 17'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'copyRequestEmail', 'sample string 18'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'copyFeeCollectionMethod', 'sample string 19'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'custom', 'sample string 20'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'pdfId', 'sample string 21'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'enableEsign', 'sample string 22'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'useBrand', 'sample string 23'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'esignAgreement', 'sample string 24'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'esignText', 'sample string 25'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'allowCDWithdraw', 'sample string 26'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'mustAgreeToEsign', 'sample string 27'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'useConsumerDisclosureWithinAccount', 'sample string 28'

    -- Adds the "Authorization: Bearer {{accessToken}}" header.
    EXEC sp_OASetProperty @http, 'AuthToken', '{{accessToken}}'
    EXEC sp_OAMethod @http, 'SetRequestHeader', NULL, 'Accept', 'application/json'

    DECLARE @sbRequestBody int
    EXEC @hr = sp_OACreate 'Chilkat_9_5_0.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/v2.1/accounts/{{accountId}}/consumer_disclosure/{{langCode}}?include_metadata={{include_metadata}}', @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 "Accept: application/json"
	-H "Authorization: Bearer {{accessToken}}"
	-d '{
  "companyName": "sample string 1",
  "companyPhone": "sample string 2",
  "withdrawEmail": "sample string 3",
  "withdrawByEmail": "sample string 4",
  "withdrawByPhone": "sample string 5",
  "withdrawByMail": "sample string 6",
  "withdrawAddressLine1": "sample string 7",
  "withdrawAddressLine2": "sample string 8",
  "withdrawCity": "sample string 9",
  "withdrawState": "sample string 10",
  "withdrawPostalCode": "sample string 11",
  "withdrawConsequences": "sample string 12",
  "withdrawOther": "sample string 13",
  "withdrawPhone": "sample string 14",
  "changeEmail": "sample string 15",
  "changeEmailOther": "sample string 16",
  "copyCostPerPage": "sample string 17",
  "copyRequestEmail": "sample string 18",
  "copyFeeCollectionMethod": "sample string 19",
  "custom": "sample string 20",
  "pdfId": "sample string 21",
  "enableEsign": "sample string 22",
  "useBrand": "sample string 23",
  "esignAgreement": "sample string 24",
  "esignText": "sample string 25",
  "allowCDWithdraw": "sample string 26",
  "mustAgreeToEsign": "sample string 27",
  "useConsumerDisclosureWithinAccount": "sample string 28"
}'
https://domain.com/v2.1/accounts/{{accountId}}/consumer_disclosure/{{langCode}}?include_metadata={{include_metadata}}

Postman Collection Item JSON

{
  "name": "Update Consumer Disclosure.",
  "request": {
    "method": "PUT",
    "header": [
      {
        "key": "Accept",
        "value": "application/json"
      },
      {
        "key": "Authorization",
        "value": "Bearer {{accessToken}}"
      }
    ],
    "body": {
      "mode": "raw",
      "raw": "{\n  \"companyName\": \"sample string 1\",\n  \"companyPhone\": \"sample string 2\",\n  \"withdrawEmail\": \"sample string 3\",\n  \"withdrawByEmail\": \"sample string 4\",\n  \"withdrawByPhone\": \"sample string 5\",\n  \"withdrawByMail\": \"sample string 6\",\n  \"withdrawAddressLine1\": \"sample string 7\",\n  \"withdrawAddressLine2\": \"sample string 8\",\n  \"withdrawCity\": \"sample string 9\",\n  \"withdrawState\": \"sample string 10\",\n  \"withdrawPostalCode\": \"sample string 11\",\n  \"withdrawConsequences\": \"sample string 12\",\n  \"withdrawOther\": \"sample string 13\",\n  \"withdrawPhone\": \"sample string 14\",\n  \"changeEmail\": \"sample string 15\",\n  \"changeEmailOther\": \"sample string 16\",\n  \"copyCostPerPage\": \"sample string 17\",\n  \"copyRequestEmail\": \"sample string 18\",\n  \"copyFeeCollectionMethod\": \"sample string 19\",\n  \"custom\": \"sample string 20\",\n  \"pdfId\": \"sample string 21\",\n  \"enableEsign\": \"sample string 22\",\n  \"useBrand\": \"sample string 23\",\n  \"esignAgreement\": \"sample string 24\",\n  \"esignText\": \"sample string 25\",\n  \"allowCDWithdraw\": \"sample string 26\",\n  \"mustAgreeToEsign\": \"sample string 27\",\n  \"useConsumerDisclosureWithinAccount\": \"sample string 28\"\n}"
    },
    "url": {
      "raw": "{{baseUrl}}/v2.1/accounts/{{accountId}}/consumer_disclosure/{{langCode}}?include_metadata={{include_metadata}}",
      "host": [
        "{{baseUrl}}"
      ],
      "path": [
        "v2.1",
        "accounts",
        "{{accountId}}",
        "consumer_disclosure",
        "{{langCode}}"
      ],
      "query": [
        {
          "key": "include_metadata",
          "value": "{{include_metadata}}"
        }
      ],
      "variable": [
        {
          "key": "accountId",
          "value": "{{accountId}}"
        },
        {
          "key": "langCode",
          "value": "{{langCode}}"
        }
      ]
    }
  },
  "response": [
  ]
}