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 Download Envelope Document (PDF)See more DocuSign ExamplesRetrieves the specified document from the envelope. The response body of this method is the PDF file as a byte stream. You can get the file name and document ID from the response's Content-Disposition header. For more information, see https://developers.docusign.com/docs/esign-rest-api/reference/envelopes/envelopedocuments/get/
-- 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/1 -- 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 @url nvarchar(4000) SELECT @url = 'https://demo.docusign.net/restapi/v2.1/accounts/{$accountId}/envelopes/{$envelopeId}/documents/1' DECLARE @bd int -- Use "Chilkat_9_5_0.BinData" for versions of Chilkat < 10.0.0 EXEC @hr = sp_OACreate 'Chilkat.BinData', @bd OUT EXEC sp_OAMethod @http, 'DownloadBd', @success OUT, @url, @bd 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 @bd RETURN END DECLARE @respStatusCode int EXEC sp_OAGetProperty @http, 'LastStatus', @respStatusCode OUT PRINT 'Response Status Code = ' + @respStatusCode IF @respStatusCode <> 200 BEGIN PRINT 'Response Header:' EXEC sp_OAGetProperty @http, 'LastResponseHeader', @sTmp0 OUT PRINT @sTmp0 -- The response body contains an error message. EXEC sp_OAMethod @bd, 'GetString', @sTmp0 OUT, 'utf-8' PRINT @sTmp0 PRINT 'Failed.' EXEC @hr = sp_OADestroy @http EXEC @hr = sp_OADestroy @jsonToken EXEC @hr = sp_OADestroy @bd RETURN END -- The response indicated success. -- Get the filename from the Content-Disposition header and save to a file. DECLARE @mime int -- Use "Chilkat_9_5_0.Mime" for versions of Chilkat < 10.0.0 EXEC @hr = sp_OACreate 'Chilkat.Mime', @mime OUT EXEC sp_OAGetProperty @http, 'LastResponseHeader', @sTmp0 OUT EXEC sp_OAMethod @mime, 'LoadMime', @success OUT, @sTmp0 DECLARE @filename nvarchar(4000) EXEC sp_OAMethod @mime, 'GetHeaderFieldAttribute', @filename OUT, 'Content-Disposition', 'filename' PRINT 'filename = ' + @filename DECLARE @sbPath int -- Use "Chilkat_9_5_0.StringBuilder" for versions of Chilkat < 10.0.0 EXEC @hr = sp_OACreate 'Chilkat.StringBuilder', @sbPath OUT EXEC sp_OAMethod @sbPath, 'Append', @success OUT, 'C:/aaworkarea/' EXEC sp_OAMethod @sbPath, 'Append', @success OUT, @filename EXEC sp_OAMethod @sbPath, 'GetAsString', @sTmp0 OUT EXEC sp_OAMethod @bd, 'WriteFile', @success OUT, @sTmp0 IF @success = 0 BEGIN PRINT 'Failed to save to output file.' END ELSE BEGIN EXEC sp_OAMethod @sbPath, 'GetAsString', @sTmp0 OUT PRINT 'Wrote ' + @sTmp0 END EXEC @hr = sp_OADestroy @http EXEC @hr = sp_OADestroy @jsonToken EXEC @hr = sp_OADestroy @bd EXEC @hr = sp_OADestroy @mime EXEC @hr = sp_OADestroy @sbPath END GO |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.