DocuSign Rest API,不能添加多个文档

本文关键字:文档 添加 不能 Rest API DocuSign | 更新日期: 2023-09-27 17:53:38

我使用以下包装器DocuSign API: https://github.com/docusign/docusign-csharp-client

一切都很好,只要我只使用一个文档。但是,如果我传入多个文档,它只使用第一个文档,因为一旦在电子邮件中单击链接,唯一可见的文档是第一个:

Dim envelope As New EnvelopeDefinition(),
        api As New EnvelopesApi()
    With envelope
        .TemplateId = _model.TemplateId
        .EmailSubject = _model.EmailSubject
        .Status = "sent"
    End With

    If _model.Documents IsNot Nothing AndAlso _model.Documents.Count > 0 Then
        Dim documents As New List(Of Document)()
        For Each doc In _model.Documents
            Dim tDoc As New Document()
            With tDoc
                .Name = doc.Name
                .FileExtension = doc.Extension.Replace(".", "")
                .DocumentId = doc.ID
                .DocumentBase64 = System.Convert.ToBase64String(doc.FileBytes)
            End With
            documents.Add(tDoc)
        Next
        envelope.Documents = documents
    End If
    If _model.Recipients IsNot Nothing AndAlso _model.Recipients.Count > 0 Then
        Dim templateRoles As New List(Of TemplateRole)()
        For Each recipient In _model.Recipients
            Dim role As New TemplateRole()
            With role
                .Email = recipient.Email
                .Name = recipient.Name
                .RoleName = recipient.RoleName
                .Tabs = New Tabs()
                .Tabs.SignHereTabs = New List(Of SignHere)
                For Each doc In envelope.Documents
                    Dim signHere As New SignHere()
                    With signHere
                        .DocumentId = doc.DocumentId
                        .AnchorString = recipient.AnchorText
                        .AnchorIgnoreIfNotPresent = "true"
                    End With
                    .Tabs.SignHereTabs.Add(signHere)
                Next
            End With
            templateRoles.Add(role)
        Next recipient
        envelope.TemplateRoles = templateRoles
    End If
    Dim summary As EnvelopeSummary = api.CreateEnvelope(_model.Authentication.AccountID, envelope)
c#范例欢迎,或者VB。NET,或者只是一般的帮助,什么可能是问题。

——UPDATE——下面是json格式的请求:

POST https: 
//demo.docusign.net:7801/restapi/v2/accounts/MYACCOUNTNUMBER/envelopes
Content - Length: 415238
Content - Type: application / json
Accept: application / json
Host: demo.docusign.net
User - Agent: RestSharp / 105.1.0.0
X - DocuSign - SDK: C #
X - DocuSign - Authentication: {
    "Username": "myusername@somewhere.com",
    "Password": "[omitted]",
    "IntegratorKey": "[omitted]"
}
X - Forwarded - For: 55.55.555.555
X - SecurityProtocol - Version: TLSv1
X - SecurityProtocol - CipherSuite: ECDHE - RSA - AES256 - CBC - SHA {
    "documents": [{
        "documentId": "1",
        "uri": null,
        "remoteUrl": null,
        "name": "Test1",
        "password": null,
        "transformPdfFields": null,
        "fileExtension": "pdf",
        "matchBoxes": null,
        "order": null,
        "pages": null,
        "documentFields": null,
        "encryptedWithKeyManager": null,
        "documentBase64": "JVBERi0xLjUNCiW1tbW1DQoxIDAgb2JqDQo8PC9UeXBlL= ETC ETC",
        "applyAnchorTabs": null
    }, {
        "documentId": "2",
        "uri": null,
        "remoteUrl": null,
        "name": "Test2",
        "password": null,
        "transformPdfFields": null,
        "fileExtension": "pdf",
        "matchBoxes": null,
        "order": null,
        "pages": null,
        "documentFields": null,
        "encryptedWithKeyManager": null,
        "documentBase64": "JVBERi0xLjUNCiW1tbW1DQoxIDAgb2JqDQo8PC9U== ETC ETC",
        "applyAnchorTabs": null
    }, {
        "documentId": "3",
        "uri": null,
        "remoteUrl": null,
        "name": "Test3",
        "password": null,
        "transformPdfFields": null,
        "fileExtension": "pdf",
        "matchBoxes": null,
        "order": null,
        "pages": null,
        "documentFields": null,
        "encryptedWithKeyManager": null,
        "documentBase64": "JVBERi0xLjUNCiW1tbW1DQoxIDAgb2JqDQo8PC9Ue ETC ETC",
        "applyAnchorTabs": null
    }],
    "recipients": null,
    "customFields": null,
    "eventNotification": null,
    "brandId": null,
    "allowRecipientRecursion": null,
    "templateId": "MYTEMPLATEID",
    "templateRoles": [{
        "email": "MYEMAIL@me.com",
        "roleName": "Customer",
        "name": "John Doe",
        "signingGroupId": null,
        "inPersonSignerName": null,
        "clientUserId": null,
        "embeddedRecipientStartURL": null,
        "defaultRecipient": null,
        "accessCode": null,
        "routingOrder": null,
        "emailNotification": null,
        "tabs": {
            "signHereTabs": [{
                "name": null,
                "tabLabel": null,
                "scaleValue": null,
                "optional": null,
                "documentId": "1",
                "recipientId": null,
                "pageNumber": null,
                "xPosition": null,
                "yPosition": null,
                "anchorString": "customeranchor",
                "anchorXOffset": null,
                "anchorYOffset": null,
                "anchorUnits": null,
                "anchorIgnoreIfNotPresent": "true",
                "anchorCaseSensitive": null,
                "anchorMatchWholeWord": null,
                "anchorHorizontalAlignment": null,
                "tabId": null,
                "templateLocked": null,
                "templateRequired": null,
                "conditionalParentLabel": null,
                "conditionalParentValue": null,
                "customTabId": null,
                "mergeField": null,
                "status": null,
                "errorDetails": null
            }, {
                "name": null,
                "tabLabel": null,
                "scaleValue": null,
                "optional": null,
                "documentId": "2",
                "recipientId": null,
                "pageNumber": null,
                "xPosition": null,
                "yPosition": null,
                "anchorString": "customeranchor",
                "anchorXOffset": null,
                "anchorYOffset": null,
                "anchorUnits": null,
                "anchorIgnoreIfNotPresent": "true",
                "anchorCaseSensitive": null,
                "anchorMatchWholeWord": null,
                "anchorHorizontalAlignment": null,
                "tabId": null,
                "templateLocked": null,
                "templateRequired": null,
                "conditionalParentLabel": null,
                "conditionalParentValue": null,
                "customTabId": null,
                "mergeField": null,
                "status": null,
                "errorDetails": null
            }, {
                "name": null,
                "tabLabel": null,
                "scaleValue": null,
                "optional": null,
                "documentId": "3",
                "recipientId": null,
                "pageNumber": null,
                "xPosition": null,
                "yPosition": null,
                "anchorString": "customeranchor",
                "anchorXOffset": null,
                "anchorYOffset": null,
                "anchorUnits": null,
                "anchorIgnoreIfNotPresent": "true",
                "anchorCaseSensitive": null,
                "anchorMatchWholeWord": null,
                "anchorHorizontalAlignment": null,
                "tabId": null,
                "templateLocked": null,
                "templateRequired": null,
                "conditionalParentLabel": null,
                "conditionalParentValue": null,
                "customTabId": null,
                "mergeField": null,
                "status": null,
                "errorDetails": null
            }],
            "initialHereTabs": null,
            "signerAttachmentTabs": null,
            "approveTabs": null,
            "declineTabs": null,
            "fullNameTabs": null,
            "dateSignedTabs": null,
            "envelopeIdTabs": null,
            "companyTabs": null,
            "titleTabs": null,
            "textTabs": null,
            "numberTabs": null,
            "ssnTabs": null,
            "dateTabs": null,
            "zipTabs": null,
            "emailTabs": null,
            "noteTabs": null,
            "checkboxTabs": null,
            "radioGroupTabs": null,
            "listTabs": null,
            "firstNameTabs": null,
            "lastNameTabs": null,
            "emailAddressTabs": null,
            "formulaTabs": null
        }
    }, {
        "email": null,
        "roleName": "Account Manager",
        "name": null,
        "signingGroupId": null,
        "inPersonSignerName": null,
        "clientUserId": null,
        "embeddedRecipientStartURL": null,
        "defaultRecipient": null,
        "accessCode": null,
        "routingOrder": null,
        "emailNotification": null,
        "tabs": {
            "signHereTabs": [{
                "name": null,
                "tabLabel": null,
                "scaleValue": null,
                "optional": null,
                "documentId": "1",
                "recipientId": null,
                "pageNumber": null,
                "xPosition": null,
                "yPosition": null,
                "anchorString": "adminanchor",
                "anchorXOffset": null,
                "anchorYOffset": null,
                "anchorUnits": null,
                "anchorIgnoreIfNotPresent": "true",
                "anchorCaseSensitive": null,
                "anchorMatchWholeWord": null,
                "anchorHorizontalAlignment": null,
                "tabId": null,
                "templateLocked": null,
                "templateRequired": null,
                "conditionalParentLabel": null,
                "conditionalParentValue": null,
                "customTabId": null,
                "mergeField": null,
                "status": null,
                "errorDetails": null
            }, {
                "name": null,
                "tabLabel": null,
                "scaleValue": null,
                "optional": null,
                "documentId": "2",
                "recipientId": null,
                "pageNumber": null,
                "xPosition": null,
                "yPosition": null,
                "anchorString": "adminanchor",
                "anchorXOffset": null,
                "anchorYOffset": null,
                "anchorUnits": null,
                "anchorIgnoreIfNotPresent": "true",
                "anchorCaseSensitive": null,
                "anchorMatchWholeWord": null,
                "anchorHorizontalAlignment": null,
                "tabId": null,
                "templateLocked": null,
                "templateRequired": null,
                "conditionalParentLabel": null,
                "conditionalParentValue": null,
                "customTabId": null,
                "mergeField": null,
                "status": null,
                "errorDetails": null
            }, {
                "name": null,
                "tabLabel": null,
                "scaleValue": null,
                "optional": null,
                "documentId": "3",
                "recipientId": null,
                "pageNumber": null,
                "xPosition": null,
                "yPosition": null,
                "anchorString": "adminanchor",
                "anchorXOffset": null,
                "anchorYOffset": null,
                "anchorUnits": null,
                "anchorIgnoreIfNotPresent": "true",
                "anchorCaseSensitive": null,
                "anchorMatchWholeWord": null,
                "anchorHorizontalAlignment": null,
                "tabId": null,
                "templateLocked": null,
                "templateRequired": null,
                "conditionalParentLabel": null,
                "conditionalParentValue": null,
                "customTabId": null,
                "mergeField": null,
                "status": null,
                "errorDetails": null
            }],
            "initialHereTabs": null,
            "signerAttachmentTabs": null,
            "approveTabs": null,
            "declineTabs": null,
            "fullNameTabs": null,
            "dateSignedTabs": null,
            "envelopeIdTabs": null,
            "companyTabs": null,
            "titleTabs": null,
            "textTabs": null,
            "numberTabs": null,
            "ssnTabs": null,
            "dateTabs": null,
            "zipTabs": null,
            "emailTabs": null,
            "noteTabs": null,
            "checkboxTabs": null,
            "radioGroupTabs": null,
            "listTabs": null,
            "firstNameTabs": null,
            "lastNameTabs": null,
            "emailAddressTabs": null,
            "formulaTabs": null
        }
    }],
    "compositeTemplates": null,
    "accessibility": null,
    "transactionId": null,
    "status": "sent",
    "documentsUri": null,
    "recipientsUri": null,
    "asynchronous": null,
    "envelopeUri": null,
    "emailSubject": "Test DocuSign - Hello World",
    "emailBlurb": null,
    "envelopeId": null,
    "signingLocation": null,
    "customFieldsUri": null,
    "envelopeIdStamping": null,
    "authoritativeCopy": null,
    "notification": null,
    "notificationUri": null,
    "enforceSignerVisibility": null,
    "enableWetSign": null,
    "allowMarkup": null,
    "allowReassign": null,
    "createdDateTime": null,
    "lastModifiedDateTime": null,
    "deliveredDateTime": null,
    "sentDateTime": null,
    "completedDateTime": null,
    "voidedDateTime": null,
    "voidedReason": null,
    "deletedDateTime": null,
    "declinedDateTime": null,
    "statusChangedDateTime": null,
    "documentsCombinedUri": null,
    "certificateUri": null,
    "templatesUri": null,
    "messageLock": null,
    "recipientsLock": null,
    "useDisclosure": null,
    "emailSettings": null,
    "purgeState": null,
    "lockInformation": null,
    "is21CFRPart11": null
}
201 Created
Content - Type: application / json;
charset = utf - 8 {
    "envelopeId": "555555555555555555",
    "uri": "/envelopes/adsfadsfadsfasdfadsfadsfasdf",
    "statusDateTime": "2016-06-30T22:22:31.5900000Z",
    "status": "sent"
}
另外

:

我可以在不使用模板的情况下附加多个文档。当使用模板时,我不能。即使我在模板中添加相同数量的文档,它也不起作用。

我已经能够使这个工作,但它似乎不正确。我的方法是使用复合模板和内联模板。

DocuSign Rest API,不能添加多个文档

根据您更新的帖子,其中指定您可以获得多个文档工作,但不是当您通过模板发送时,系统是按照设计工作的,这里没有错误。

我想你基本上已经回答了你自己的问题,如果你想组合一个模板和额外的文档,或者两个或更多的模板在一起,或者模板和文档的任何其他组合,那么是的,你需要使用compositeTemplates节点。

下面是一些关于复合模板的额外资源:

  • 开发者中心-模板说明
  • API Docs - Envelope创建API(见下面的复合模板部分)
  • GitHub示例(参见第三个示例,它结合了两个模板)

正如Ergin在他的评论中所说,平台对传入的API调用做出反应,因此您需要显示传入的API请求本身以获得最佳答案。

这是一篇关于获取API日志的博文。

与此同时,这里有一些想法:

  1. 确保两个文档的documentId不同
  2. 示例:查看多文档配方,了解多文档如何工作
  3. 如果您的文档特别大(>20MB左右),那么您可能超过了最大调用大小。解决方案:首先用草稿模式创建一个文档的信封,然后通过单独的调用添加第二个文档。

代替。documentbase64 = System.Convert.ToBase64String(doc.FileBytes)使用以下函数:.DocumentBase64 = System.Convert.ToBase64String(ReadContent(doc))

Private Function ReadContent(ByVal fileName As String) As Byte()
    Dim tempByte() As Byte = Nothing
    If String.IsNullOrEmpty(fileName) Then
        Throw New ArgumentNullException("FileName Not Provided")
        Return Nothing
    End If
    Try
        Dim fileInfo As New FileInfo(fileName)
        Dim numBytes As Long = fileInfo.Length
        Dim fStream As New FileStream(fileName, FileMode.Open, FileAccess.Read)
        Dim binaryReader As New BinaryReader(fStream)
        tempByte = binaryReader.ReadBytes(Convert.ToInt32(numBytes))
        fileInfo = Nothing
        numBytes = 0
        fStream.Close()
        fStream.Dispose()
        Return tempByte
    Catch ex As Exception
        Return Nothing
    End Try
End Function