Chilkat Online Tools

SQL Server / DocuSign REST API / Adds user Signature and initials images to a Signature.

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.

    -- {
    --   "userSignatures": [
    --     {
    --       "signatureId": "sample string 1",
    --       "stampType": "sample string 2",
    --       "phoneticName": "sample string 3",
    --       "imageType": "sample string 4",
    --       "externalID": "sample string 5",
    --       "stampSizeMM": "sample string 6",
    --       "stampFormat": "sample string 7",
    --       "dateStampProperties": {
    --         "dateAreaX": "sample string 1",
    --         "dateAreaY": "sample string 2",
    --         "dateAreaWidth": "sample string 3",
    --         "dateAreaHeight": "sample string 4"
    --       },
    --       "stampImageUri": "sample string 8",
    --       "signatureFont": "sample string 9",
    --       "signatureType": "sample string 10",
    --       "signatureName": "sample string 11",
    --       "signatureImageUri": "sample string 12",
    --       "signatureInitials": "sample string 13",
    --       "initialsImageUri": "sample string 14",
    --       "createdDateTime": "sample string 15",
    --       "adoptedDateTime": "sample string 16",
    --       "signature150ImageId": "sample string 17",
    --       "initials150ImageId": "sample string 18"
    --     }
    --   ]
    -- }

    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, 'userSignatures[0].signatureId', 'sample string 1'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'userSignatures[0].stampType', 'sample string 2'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'userSignatures[0].phoneticName', 'sample string 3'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'userSignatures[0].imageType', 'sample string 4'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'userSignatures[0].externalID', 'sample string 5'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'userSignatures[0].stampSizeMM', 'sample string 6'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'userSignatures[0].stampFormat', 'sample string 7'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'userSignatures[0].dateStampProperties.dateAreaX', 'sample string 1'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'userSignatures[0].dateStampProperties.dateAreaY', 'sample string 2'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'userSignatures[0].dateStampProperties.dateAreaWidth', 'sample string 3'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'userSignatures[0].dateStampProperties.dateAreaHeight', 'sample string 4'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'userSignatures[0].stampImageUri', 'sample string 8'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'userSignatures[0].signatureFont', 'sample string 9'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'userSignatures[0].signatureType', 'sample string 10'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'userSignatures[0].signatureName', 'sample string 11'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'userSignatures[0].signatureImageUri', 'sample string 12'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'userSignatures[0].signatureInitials', 'sample string 13'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'userSignatures[0].initialsImageUri', 'sample string 14'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'userSignatures[0].createdDateTime', 'sample string 15'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'userSignatures[0].adoptedDateTime', 'sample string 16'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'userSignatures[0].signature150ImageId', 'sample string 17'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'userSignatures[0].initials150ImageId', 'sample string 18'

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

    DECLARE @resp int
    EXEC sp_OAMethod @http, 'PostJson3', @resp OUT, 'https://domain.com/v2.1/accounts/{{accountId}}/users/{{userId}}/signatures', 'application/json', @json
    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
        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


END
GO

Curl Command

curl -X POST
	-H "Accept: application/json"
	-H "Authorization: Bearer {{accessToken}}"
	-d '{
  "userSignatures": [
    {
      "signatureId": "sample string 1",
      "stampType": "sample string 2",
      "phoneticName": "sample string 3",
      "imageType": "sample string 4",
      "externalID": "sample string 5",
      "stampSizeMM": "sample string 6",
      "stampFormat": "sample string 7",
      "dateStampProperties": {
        "dateAreaX": "sample string 1",
        "dateAreaY": "sample string 2",
        "dateAreaWidth": "sample string 3",
        "dateAreaHeight": "sample string 4"
      },
      "stampImageUri": "sample string 8",
      "signatureFont": "sample string 9",
      "signatureType": "sample string 10",
      "signatureName": "sample string 11",
      "signatureImageUri": "sample string 12",
      "signatureInitials": "sample string 13",
      "initialsImageUri": "sample string 14",
      "createdDateTime": "sample string 15",
      "adoptedDateTime": "sample string 16",
      "signature150ImageId": "sample string 17",
      "initials150ImageId": "sample string 18"
    }
  ]
}'
https://domain.com/v2.1/accounts/{{accountId}}/users/{{userId}}/signatures

Postman Collection Item JSON

{
  "name": "Adds user Signature and initials images to a Signature.",
  "request": {
    "method": "POST",
    "header": [
      {
        "key": "Accept",
        "value": "application/json"
      },
      {
        "key": "Authorization",
        "value": "Bearer {{accessToken}}"
      }
    ],
    "body": {
      "mode": "raw",
      "raw": "{\n  \"userSignatures\": [\n    {\n      \"signatureId\": \"sample string 1\",\n      \"stampType\": \"sample string 2\",\n      \"phoneticName\": \"sample string 3\",\n      \"imageType\": \"sample string 4\",\n      \"externalID\": \"sample string 5\",\n      \"stampSizeMM\": \"sample string 6\",\n      \"stampFormat\": \"sample string 7\",\n      \"dateStampProperties\": {\n        \"dateAreaX\": \"sample string 1\",\n        \"dateAreaY\": \"sample string 2\",\n        \"dateAreaWidth\": \"sample string 3\",\n        \"dateAreaHeight\": \"sample string 4\"\n      },\n      \"stampImageUri\": \"sample string 8\",\n      \"signatureFont\": \"sample string 9\",\n      \"signatureType\": \"sample string 10\",\n      \"signatureName\": \"sample string 11\",\n      \"signatureImageUri\": \"sample string 12\",\n      \"signatureInitials\": \"sample string 13\",\n      \"initialsImageUri\": \"sample string 14\",\n      \"createdDateTime\": \"sample string 15\",\n      \"adoptedDateTime\": \"sample string 16\",\n      \"signature150ImageId\": \"sample string 17\",\n      \"initials150ImageId\": \"sample string 18\"\n    }\n  ]\n}"
    },
    "url": {
      "raw": "{{baseUrl}}/v2.1/accounts/{{accountId}}/users/{{userId}}/signatures",
      "host": [
        "{{baseUrl}}"
      ],
      "path": [
        "v2.1",
        "accounts",
        "{{accountId}}",
        "users",
        "{{userId}}",
        "signatures"
      ],
      "variable": [
        {
          "key": "accountId",
          "value": "{{accountId}}"
        },
        {
          "key": "userId",
          "value": "{{userId}}"
        }
      ]
    },
    "description": "Adds a user signature image and/or user initials image to the specified user. \n\nThe userId property specified in the endpoint must match the authenticated user's userId and the user must be a member of the account.\n\nThe rules and processes associated with this are:\n\n* If Content-Type is set to application/json, then the default behavior for creating a default signature image, based on the name and a DocuSign font, is used.\n* If Content-Type is set to multipart/form-data, then the request must contain a first part with the user signature information, followed by parts that contain the images.\n\nFor each Image part, the Content-Disposition header has a \"filename\" value that is used to map to the `signatureName` and/or `signatureInitials` properties in the JSON to the image. \n\nFor example: \n`Content-Disposition: file; filename=\"Ron Test20121127083900\"`\n\nIf no matching image (by filename value) is found, then the image is not set. One, both, or neither of the signature and initials images can be set with this call.\n\nThe Content-Transfer-Encoding: base64 header, set in the header for the part containing the image, can be set to indicate that the images are formatted as base64 instead of as binary.\n\nIf successful, 200-OK is returned, and a JSON structure containing the signature information is provided, note that the signatureId can change with each API POST, PUT, or DELETE since the changes to the signature structure cause the current signature to be closed, and a new signature record to be created."
  },
  "response": [
  ]
}