Chilkat Online Tools

SQL Server / DocuSign REST API / Gets the definition of a template.

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

    DECLARE @queryParams int
    -- Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0
    EXEC @hr = sp_OACreate 'Chilkat.JsonObject', @queryParams OUT

    EXEC sp_OAMethod @queryParams, 'UpdateString', @success OUT, 'count', '{{count}}'
    EXEC sp_OAMethod @queryParams, 'UpdateString', @success OUT, 'created_from_date', '{{created_from_date}}'
    EXEC sp_OAMethod @queryParams, 'UpdateString', @success OUT, 'created_to_date', '{{created_to_date}}'
    EXEC sp_OAMethod @queryParams, 'UpdateString', @success OUT, 'folder_ids', '{{folder_ids}}'
    EXEC sp_OAMethod @queryParams, 'UpdateString', @success OUT, 'folder_types', '{{folder_types}}'
    EXEC sp_OAMethod @queryParams, 'UpdateString', @success OUT, 'from_date', '{{from_date}}'
    EXEC sp_OAMethod @queryParams, 'UpdateString', @success OUT, 'include', '{{include}}'
    EXEC sp_OAMethod @queryParams, 'UpdateString', @success OUT, 'is_deleted_template_only', '{{is_deleted_template_only}}'
    EXEC sp_OAMethod @queryParams, 'UpdateString', @success OUT, 'is_download', '{{is_download}}'
    EXEC sp_OAMethod @queryParams, 'UpdateString', @success OUT, 'modified_from_date', '{{modified_from_date}}'
    EXEC sp_OAMethod @queryParams, 'UpdateString', @success OUT, 'modified_to_date', '{{modified_to_date}}'
    EXEC sp_OAMethod @queryParams, 'UpdateString', @success OUT, 'order', '{{order}}'
    EXEC sp_OAMethod @queryParams, 'UpdateString', @success OUT, 'order_by', '{{order_by}}'
    EXEC sp_OAMethod @queryParams, 'UpdateString', @success OUT, 'search_fields', '{{search_fields}}'
    EXEC sp_OAMethod @queryParams, 'UpdateString', @success OUT, 'search_text', '{{search_text}}'
    EXEC sp_OAMethod @queryParams, 'UpdateString', @success OUT, 'shared_by_me', '{{shared_by_me}}'
    EXEC sp_OAMethod @queryParams, 'UpdateString', @success OUT, 'start_position', '{{start_position}}'
    EXEC sp_OAMethod @queryParams, 'UpdateString', @success OUT, 'template_ids', '{{template_ids}}'
    EXEC sp_OAMethod @queryParams, 'UpdateString', @success OUT, 'to_date', '{{to_date}}'
    EXEC sp_OAMethod @queryParams, 'UpdateString', @success OUT, 'used_from_date', '{{used_from_date}}'
    EXEC sp_OAMethod @queryParams, 'UpdateString', @success OUT, 'used_to_date', '{{used_to_date}}'
    EXEC sp_OAMethod @queryParams, 'UpdateString', @success OUT, 'user_filter', '{{user_filter}}'
    EXEC sp_OAMethod @queryParams, 'UpdateString', @success OUT, 'user_id', '{{user_id}}'

    -- 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, 'QuickRequestParams', @resp OUT, 'GET', 'https://domain.com/v2.1/accounts/{{accountId}}/templates', @queryParams
    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 @queryParams
        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 @queryParams


END
GO

Curl Command

curl -G -d "count=%7B%7Bcount%7D%7D"
	-d "created_from_date=%7B%7Bcreated_from_date%7D%7D"
	-d "created_to_date=%7B%7Bcreated_to_date%7D%7D"
	-d "folder_ids=%7B%7Bfolder_ids%7D%7D"
	-d "folder_types=%7B%7Bfolder_types%7D%7D"
	-d "from_date=%7B%7Bfrom_date%7D%7D"
	-d "include=%7B%7Binclude%7D%7D"
	-d "is_deleted_template_only=%7B%7Bis_deleted_template_only%7D%7D"
	-d "is_download=%7B%7Bis_download%7D%7D"
	-d "modified_from_date=%7B%7Bmodified_from_date%7D%7D"
	-d "modified_to_date=%7B%7Bmodified_to_date%7D%7D"
	-d "order=%7B%7Border%7D%7D"
	-d "order_by=%7B%7Border_by%7D%7D"
	-d "search_fields=%7B%7Bsearch_fields%7D%7D"
	-d "search_text=%7B%7Bsearch_text%7D%7D"
	-d "shared_by_me=%7B%7Bshared_by_me%7D%7D"
	-d "start_position=%7B%7Bstart_position%7D%7D"
	-d "template_ids=%7B%7Btemplate_ids%7D%7D"
	-d "to_date=%7B%7Bto_date%7D%7D"
	-d "used_from_date=%7B%7Bused_from_date%7D%7D"
	-d "used_to_date=%7B%7Bused_to_date%7D%7D"
	-d "user_filter=%7B%7Buser_filter%7D%7D"
	-d "user_id=%7B%7Buser_id%7D%7D"
	-H "Accept: application/json"
	-H "Authorization: Bearer {{accessToken}}"
https://domain.com/v2.1/accounts/{{accountId}}/templates

Postman Collection Item JSON

{
  "name": "Gets the definition of a template.",
  "request": {
    "method": "GET",
    "header": [
      {
        "key": "Accept",
        "value": "application/json"
      },
      {
        "key": "Authorization",
        "value": "Bearer {{accessToken}}"
      }
    ],
    "url": {
      "raw": "{{baseUrl}}/v2.1/accounts/{{accountId}}/templates?count={{count}}&created_from_date={{created_from_date}}&created_to_date={{created_to_date}}&folder_ids={{folder_ids}}&folder_types={{folder_types}}&from_date={{from_date}}&include={{include}}&is_deleted_template_only={{is_deleted_template_only}}&is_download={{is_download}}&modified_from_date={{modified_from_date}}&modified_to_date={{modified_to_date}}&order={{order}}&order_by={{order_by}}&search_fields={{search_fields}}&search_text={{search_text}}&shared_by_me={{shared_by_me}}&start_position={{start_position}}&template_ids={{template_ids}}&to_date={{to_date}}&used_from_date={{used_from_date}}&used_to_date={{used_to_date}}&user_filter={{user_filter}}&user_id={{user_id}}",
      "host": [
        "{{baseUrl}}"
      ],
      "path": [
        "v2.1",
        "accounts",
        "{{accountId}}",
        "templates"
      ],
      "query": [
        {
          "key": "count",
          "value": "{{count}}"
        },
        {
          "key": "created_from_date",
          "value": "{{created_from_date}}"
        },
        {
          "key": "created_to_date",
          "value": "{{created_to_date}}"
        },
        {
          "key": "folder_ids",
          "value": "{{folder_ids}}"
        },
        {
          "key": "folder_types",
          "value": "{{folder_types}}"
        },
        {
          "key": "from_date",
          "value": "{{from_date}}"
        },
        {
          "key": "include",
          "value": "{{include}}"
        },
        {
          "key": "is_deleted_template_only",
          "value": "{{is_deleted_template_only}}"
        },
        {
          "key": "is_download",
          "value": "{{is_download}}"
        },
        {
          "key": "modified_from_date",
          "value": "{{modified_from_date}}"
        },
        {
          "key": "modified_to_date",
          "value": "{{modified_to_date}}"
        },
        {
          "key": "order",
          "value": "{{order}}"
        },
        {
          "key": "order_by",
          "value": "{{order_by}}"
        },
        {
          "key": "search_fields",
          "value": "{{search_fields}}"
        },
        {
          "key": "search_text",
          "value": "{{search_text}}"
        },
        {
          "key": "shared_by_me",
          "value": "{{shared_by_me}}"
        },
        {
          "key": "start_position",
          "value": "{{start_position}}"
        },
        {
          "key": "template_ids",
          "value": "{{template_ids}}"
        },
        {
          "key": "to_date",
          "value": "{{to_date}}"
        },
        {
          "key": "used_from_date",
          "value": "{{used_from_date}}"
        },
        {
          "key": "used_to_date",
          "value": "{{used_to_date}}"
        },
        {
          "key": "user_filter",
          "value": "{{user_filter}}"
        },
        {
          "key": "user_id",
          "value": "{{user_id}}"
        }
      ],
      "variable": [
        {
          "key": "accountId",
          "value": "{{accountId}}"
        }
      ]
    },
    "description": "Retrieves the list of templates for the specified account. The request can be limited to a specific folder."
  },
  "response": [
  ]
}