Chilkat HOME .NET Core C# Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi ActiveX Delphi DLL Go Java Lianja Mono C# Node.js Objective-C PHP ActiveX PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift 2 Swift 3,4,5... Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(SQL Server) DocuSign List Envelope DocumentsSee more DocuSign ExamplesRetrieve a list of all documents within a specific envelope. For more information, see https://developers.docusign.com/docs/esign-rest-api/reference/envelopes/envelopedocuments/list/
-- Important: See this note about string length limitations for strings returned by sp_OAMethod calls. -- CREATE PROCEDURE ChilkatSample AS BEGIN DECLARE @hr 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 -- Implements the following HTTP request: -- GET /restapi/v2.1/accounts/{accountId}/envelopes/{envelopeId}/documents -- Adds the "Authorization: Bearer eyJ0eXAi.....UE8Kl_V8KroQ" header. DECLARE @jsonToken int -- Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0 EXEC @hr = sp_OACreate 'Chilkat.JsonObject', @jsonToken OUT -- Load a previously obtained OAuth2 access token. EXEC sp_OAMethod @jsonToken, 'LoadFile', @success OUT, 'qa_data/tokens/docusign.json' IF @success = 0 BEGIN EXEC sp_OAGetProperty @jsonToken, 'LastErrorText', @sTmp0 OUT PRINT @sTmp0 EXEC @hr = sp_OADestroy @http EXEC @hr = sp_OADestroy @jsonToken RETURN END EXEC sp_OAMethod @jsonToken, 'StringOf', @sTmp0 OUT, 'access_token' EXEC sp_OASetProperty @http, 'AuthToken', @sTmp0 -- Use your account ID and a valid envelopeId here: EXEC sp_OAMethod @http, 'SetUrlVar', @success OUT, 'accountId', '7f3f65ed-5e87-418d-94c1-92499ddc8252' EXEC sp_OAMethod @http, 'SetUrlVar', @success OUT, 'envelopeId', '90d7e40a-b4bd-4ccd-bf38-c80e37954a13' DECLARE @sbResponseBody int -- Use "Chilkat_9_5_0.StringBuilder" for versions of Chilkat < 10.0.0 EXEC @hr = sp_OACreate 'Chilkat.StringBuilder', @sbResponseBody OUT EXEC sp_OAMethod @http, 'QuickGetSb', @success OUT, 'https://demo.docusign.net/restapi/v2.1/accounts/{$accountId}/envelopes/{$envelopeId}/documents', @sbResponseBody IF @success = 0 BEGIN EXEC sp_OAGetProperty @http, 'LastErrorText', @sTmp0 OUT PRINT @sTmp0 EXEC @hr = sp_OADestroy @http EXEC @hr = sp_OADestroy @jsonToken EXEC @hr = sp_OADestroy @sbResponseBody RETURN END DECLARE @jResp int -- Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0 EXEC @hr = sp_OACreate 'Chilkat.JsonObject', @jResp OUT EXEC sp_OAMethod @jResp, 'LoadSb', @success OUT, @sbResponseBody EXEC sp_OASetProperty @jResp, 'EmitCompact', 0 PRINT 'Response Body:' EXEC sp_OAMethod @jResp, 'Emit', @sTmp0 OUT PRINT @sTmp0 DECLARE @respStatusCode int EXEC sp_OAGetProperty @http, 'LastStatus', @respStatusCode OUT PRINT 'Response Status Code = ' + @respStatusCode IF @respStatusCode >= 400 BEGIN PRINT 'Response Header:' EXEC sp_OAGetProperty @http, 'LastHeader', @sTmp0 OUT PRINT @sTmp0 PRINT 'Failed.' EXEC @hr = sp_OADestroy @http EXEC @hr = sp_OADestroy @jsonToken EXEC @hr = sp_OADestroy @sbResponseBody EXEC @hr = sp_OADestroy @jResp RETURN END -- Sample JSON response: -- (Sample code for parsing the JSON response is shown below) -- { -- "envelopeId": "90d7e40a-b4bd-4ccd-bf38-c80e37954a13", -- "envelopeDocuments": [ -- { -- "documentId": "1", -- "documentIdGuid": "ca1d3cc6-9bc3-48d6-a5d8-a85d9acdcde1", -- "name": "helloWorld.pdf", -- "type": "content", -- "uri": "/envelopes/90d7e40a-b4bd-4ccd-bf38-c80e37954a13/documents/1", -- "order": "1", -- "pages": [ -- { -- "pageId": "fbf93a36-6b60-484d-94bd-ee3c08c0a546", -- "sequence": "1", -- "height": "842", -- "width": "595", -- "dpi": "72" -- } -- ], -- "availableDocumentTypes": [ -- { -- "type": "electronic", -- "isDefault": "true" -- } -- ], -- "display": "inline", -- "includeInDownload": "true", -- "signerMustAcknowledge": "no_interaction", -- "templateRequired": "false", -- "authoritativeCopy": "false" -- }, -- { -- "documentId": "certificate", -- "documentIdGuid": "7479a5de-8d91-44a2-bc33-b76a9ba0f6e2", -- "name": "Summary", -- "type": "summary", -- "uri": "/envelopes/90d7e40a-b4bd-4ccd-bf38-c80e37954a13/documents/certificate", -- "order": "999", -- "availableDocumentTypes": [ -- { -- "type": "electronic", -- "isDefault": "true" -- } -- ], -- "display": "inline", -- "includeInDownload": "true", -- "signerMustAcknowledge": "no_interaction", -- "templateRequired": "false", -- "authoritativeCopy": "false" -- } -- ] -- } -- Sample code for parsing the JSON response... -- Use the following online tool to generate parsing code from sample JSON: -- Generate Parsing Code from JSON DECLARE @documentId nvarchar(4000) DECLARE @documentIdGuid nvarchar(4000) DECLARE @name nvarchar(4000) DECLARE @v_type nvarchar(4000) DECLARE @uri nvarchar(4000) DECLARE @order nvarchar(4000) DECLARE @display nvarchar(4000) DECLARE @includeInDownload nvarchar(4000) DECLARE @signerMustAcknowledge nvarchar(4000) DECLARE @templateRequired nvarchar(4000) DECLARE @authoritativeCopy nvarchar(4000) DECLARE @j int DECLARE @count_j int DECLARE @pageId nvarchar(4000) DECLARE @sequence nvarchar(4000) DECLARE @height nvarchar(4000) DECLARE @width nvarchar(4000) DECLARE @dpi nvarchar(4000) DECLARE @isDefault nvarchar(4000) DECLARE @envelopeId nvarchar(4000) EXEC sp_OAMethod @jResp, 'StringOf', @envelopeId OUT, 'envelopeId' DECLARE @i int SELECT @i = 0 DECLARE @count_i int EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_i OUT, 'envelopeDocuments' WHILE @i < @count_i BEGIN EXEC sp_OASetProperty @jResp, 'I', @i EXEC sp_OAMethod @jResp, 'StringOf', @documentId OUT, 'envelopeDocuments[i].documentId' EXEC sp_OAMethod @jResp, 'StringOf', @documentIdGuid OUT, 'envelopeDocuments[i].documentIdGuid' EXEC sp_OAMethod @jResp, 'StringOf', @name OUT, 'envelopeDocuments[i].name' EXEC sp_OAMethod @jResp, 'StringOf', @v_type OUT, 'envelopeDocuments[i].type' EXEC sp_OAMethod @jResp, 'StringOf', @uri OUT, 'envelopeDocuments[i].uri' EXEC sp_OAMethod @jResp, 'StringOf', @order OUT, 'envelopeDocuments[i].order' EXEC sp_OAMethod @jResp, 'StringOf', @display OUT, 'envelopeDocuments[i].display' EXEC sp_OAMethod @jResp, 'StringOf', @includeInDownload OUT, 'envelopeDocuments[i].includeInDownload' EXEC sp_OAMethod @jResp, 'StringOf', @signerMustAcknowledge OUT, 'envelopeDocuments[i].signerMustAcknowledge' EXEC sp_OAMethod @jResp, 'StringOf', @templateRequired OUT, 'envelopeDocuments[i].templateRequired' EXEC sp_OAMethod @jResp, 'StringOf', @authoritativeCopy OUT, 'envelopeDocuments[i].authoritativeCopy' SELECT @j = 0 EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_j OUT, 'envelopeDocuments[i].pages' WHILE @j < @count_j BEGIN EXEC sp_OASetProperty @jResp, 'J', @j EXEC sp_OAMethod @jResp, 'StringOf', @pageId OUT, 'envelopeDocuments[i].pages[j].pageId' EXEC sp_OAMethod @jResp, 'StringOf', @sequence OUT, 'envelopeDocuments[i].pages[j].sequence' EXEC sp_OAMethod @jResp, 'StringOf', @height OUT, 'envelopeDocuments[i].pages[j].height' EXEC sp_OAMethod @jResp, 'StringOf', @width OUT, 'envelopeDocuments[i].pages[j].width' EXEC sp_OAMethod @jResp, 'StringOf', @dpi OUT, 'envelopeDocuments[i].pages[j].dpi' SELECT @j = @j + 1 END SELECT @j = 0 EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_j OUT, 'envelopeDocuments[i].availableDocumentTypes' WHILE @j < @count_j BEGIN EXEC sp_OASetProperty @jResp, 'J', @j EXEC sp_OAMethod @jResp, 'StringOf', @v_type OUT, 'envelopeDocuments[i].availableDocumentTypes[j].type' EXEC sp_OAMethod @jResp, 'StringOf', @isDefault OUT, 'envelopeDocuments[i].availableDocumentTypes[j].isDefault' SELECT @j = @j + 1 END SELECT @i = @i + 1 END EXEC @hr = sp_OADestroy @http EXEC @hr = sp_OADestroy @jsonToken EXEC @hr = sp_OADestroy @sbResponseBody EXEC @hr = sp_OADestroy @jResp END GO |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.