Docusign restapi使用信封ID和文档ID下载文档

时间:2017-06-29 07:26:47

标签: vb.net restsharp docusignapi

我们在完成从docusign下载更新文件时遇到困难。我们正在执行以下restapi请求并获取数据,但不确定如何使用响应创建文档。

Restapi请求:

GET https://demo.docusign.net/restapi/v2/accounts/xxxxx/envelopes/xxxxxx-    xxxxx-xxxxxxx-xxxxxxx/documents/1 HTTP/1.1
Accept: application/xml
Accept-Encoding: gzip, deflate, sdch
Accept-Language: en-AU,en;q=0.8,en-US;q=0.6
Content-Type: application/x-www-form-urlencoded
X-DocuSign-Authentication: { "Username" : "xxxxxxx", "Password" : "xxxxxxxx", "IntegratorKey" : "xxxxxxxxx" }
User-Agent: RestSharp/104.4.0.0
Host: demo.docusign.net
Connection: Keep-Alive

任何人都可以建议一旦我们得到回复将其保存为.pdf需要做什么。我们正在使用Vb.net平台。

1 个答案:

答案 0 :(得分:0)

您可以使用https://www.statalist.org/forums/forum/general-stata-discussion/general/1399901-how-can-i-keep-a-time-interval-around-an-event nuget包并拨打DocuSign api。

以下是下载文档的示例VB.net代码。查看完整代码DocuSign.eSign.dll

Public Class DocuSignApiTest
     Public Sub GetDocumentRecipe()
         Dim envelopeId As String = "<EnvelopeId>"
         Dim accountId As String = Init()
         Dim envApi = New EnvelopesApi()
         Dim docStream = envApi.GetDocument(accountId, envelopeId, "1")

         ' let's save the document to local file system
         Dim filePath As String = "C:\temp\" + Path.GetRandomFileName() + ".pdf"

         Using stream = File.Create(filePath)
             docStream.CopyTo(stream)
         End Using
     End Sub

     Public Function Init() As String


         Dim username As String = "<Username>"
         Dim password As String = "<Password>"
         Dim integratorKey As String = "<IntegratorKey>"

         ' initialize client for desired environment (for production change to www)
         Dim apiClient As New ApiClient("https://demo.docusign.net/restapi")
         Configuration.[Default].ApiClient = apiClient

         ' configure 'X-DocuSign-Authentication' header
         Dim authHeader As String = "{""Username"":""" + username + """, ""Password"":""" + password + """, ""IntegratorKey"":""" + integratorKey + """}"
         Configuration.[Default].AddDefaultHeader("X-DocuSign-Authentication", authHeader)

         ' we will retrieve this from the login API call
         Dim accountId As String = Nothing

         '''//////////////////////////////////////////////////////////////
         ' STEP 1: LOGIN API        
         '''//////////////////////////////////////////////////////////////

         ' login call is available in the authentication api 
         Dim authApi As New AuthenticationApi()
         Dim loginInfo As LoginInformation = authApi.Login()

         ' parse the first account ID that is returned (user might belong to multiple accounts)
         accountId = loginInfo.LoginAccounts(0).AccountId

         ' Update ApiClient with the new base url from login call
         apiClient = New ApiClient(loginInfo.LoginAccounts(0).BaseUrl)

         Return accountId
     End Function

 End Class