-->

让未指定的错误中的DocuSign API而使用合成模板(getting unspecified e

2019-10-28 08:55发布

嗨,我试图用复合模板俱乐部一个模板,在创建信封添加文档。

完整的请求之下。

但是我得到“UNSPECIFIED_ERROR”,如下图

我是新来使用的DocuSign和复合模板API。

这将是巨大的,如果我提到网上的材料有关复合模板后试图请求有人能指出我的错误。

谢谢阅读!!!

响应:

{
errorCode: "UNSPECIFIED_ERROR"
message: "An item with the same key has already been added."
}

请求

POST https://demo.docusign.net/restapi/v2/accounts/ACTID/envelopes HTTP/1.1
Host: demo.docusign.net
Connection: keep-alive
Content-Length: 6640
X-DocuSign-Authentication: <DocuSignCredentials><Username>username.com</Username><Password>PA$$W0RD</Password><IntegratorKey>INTG KEY</IntegratorKey></DocuSignCredentials>
Content-Type: multipart/form-data; boundary=MY_BOUNDARY

--MY_BOUNDARY
Content-Type: application/json
Content-Disposition: form-data
{
    "accountId": "act_ID",
    "brandId": "brnd_ID",
    "status": "SENT",
    "compositeTemplates": [
        {
            "serverTemplates": [
                {
                    "sequence": 1,
                    "templateId": "temp_ID_1"
                }
            ],
            "inlineTemplates": [
                {
                    "sequence": 1,
                    "recipients": {
                        "signers": [
                            {
                                "name": "Signer Name",
                                "email": "signer@email.com",
                                "recipientId": "1",
                                "roleName": "signer",
                                "tabs": {
                                    "textTabs": [
                                        {
                                            "tabLabel": "SignerRole",
                                            "value": "signerRole"
                                        },
                                        {
                                            "tabLabel": "SignerAddress",
                                            "value": "test TT DEMO"
                                        },
                                        {
                                            "tabLabel": "date",
                                            "value": "05/10/2014"
                                        }
                                    ]
                                }
                            }
                        ],
                        "carbonCopies": [
                            {
                                "name": "CarbonCopyName",
                                "email": "carboncopy@emailcom",
                                "recipientId": "1",
                                "roleName": "carbonCopyRole"
                            }
                        ]
                    }
                }
            ]
        },
        {
            "inlineTemplates": [
                {
                    "sequence": 2,
                    "document": {
                        "name": "body.pdf"
                    }
                }
            ]
        }
    ]
}
--MY_BOUNDARY
Content-Type: application/pdf
Content-Disposition: file; filename="body.pdf"
%PDF-1.4
%????
2 0 obj
<<
--MY_BOUNDARY--

Answer 1:

请求中的每个个体compositeTemplate对象必须同时指定:

  • 文件(S) -或者通过serverTemplate(S)或经由指定的是请求的一部分独立文件中定义

  • 收件人

例如,下面的多部分请求将创建一个包含从服务器模板文件的信封,其次是在请求中指定的其他文档:

POST https://demo.docusign.net/restapi/v2/accounts/201105/envelopes HTTP/1.1
X-DocuSign-Authentication: {"Username":"username@test.com","Password":"mypassword","IntegratorKey":"ABCD-dbd5f342-d9f6-47c3-b293-xxxxxxxxxxxx"}
Content-Type: multipart/form-data; boundary=MY_BOUNDARY
Accept: application/json
Host: demo.docusign.net
Content-Length: 272956
Expect: 100-continue


--MY_BOUNDARY
Content-Type: application/json
Content-Disposition: form-data

{
    "status" : "sent",
    "emailSubject" : "Test Envelope Subject",
    "emailBlurb" : "Test Envelope Blurb",
    "compositeTemplates": [
    {
        "serverTemplates": [
        {
            "sequence" : 1,
            "templateId": "TEMPLATE_ID"
        }],
        "inlineTemplates": [
        {
            "sequence" : 2,
            "recipients": {
                "signers" : [{
                    "email": "abbysemail@outlook.com",
                    "name": "Abby Abbott",
                    "recipientId": "1",
                    "roleName": "Initiator",
                    "routingOrder":"1"
                }
                ]
            }
        }]
    },
    {
        "inlineTemplates": [
        {
            "sequence" : 1,
            "recipients": {
                "signers" : [{
                    "email": "abbysemail@outlook.com",
                    "name": "Abby Abbott",
                    "recipientId": "1"
                }]
            }
        }],
        "document": {
            "documentId": 1,
            "name": "Customer Agreement",
            "fileExtension": "pdf"
        }
    }
]}
--MY_BOUNDARY
Content-Type: application/pdf
Content-Disposition: file; filename="CustomerAgreement.pdf"; documentid="1"

PDF_BYTE_STREAM_HERE
--MY_BOUNDARY--

如果我想的更多的文档首先出现在信封,我只会掉在请求compositeTemplate对象的顺序,从而使文件在服务器模板之前规定:

POST https://demo.docusign.net/restapi/v2/accounts/201105/envelopes HTTP/1.1
X-DocuSign-Authentication: {"Username":"username@test.com","Password":"mypassword","IntegratorKey":"ABCD-dbd5f342-d9f6-47c3-b293-xxxxxxxxxxxx"}
Content-Type: multipart/form-data; boundary=MY_BOUNDARY
Accept: application/json
Host: demo.docusign.net
Content-Length: 272956
Expect: 100-continue


--MY_BOUNDARY
Content-Type: application/json
Content-Disposition: form-data

{
    "status" : "sent",
    "emailSubject" : "Test Envelope Subject",
    "emailBlurb" : "Test Envelope Blurb",
    "compositeTemplates": [
    {
        "inlineTemplates": [
        {
            "sequence" : 1,
            "recipients": {
                "signers" : [{
                    "email": "abbysemail@outlook.com",
                    "name": "Abby Abbott",
                    "recipientId": "1"
                }]
            }
        }],
        "document": {
            "documentId": 1,
            "name": "Customer Agreement",
            "fileExtension": "pdf"
        }
    },
    {
        "serverTemplates": [
        {
            "sequence" : 1,
            "templateId": "TEMPLATE_ID"
        }],
        "inlineTemplates": [
        {
            "sequence" : 2,
            "recipients": {
                "signers" : [{
                    "email": "abbysemail@outlook.com",
                    "name": "Abby Abbott",
                    "recipientId": "1",
                    "roleName": "Initiator",
                    "routingOrder":"1"
                }
                ]
            }
        }]
    }
]}
--MY_BOUNDARY
Content-Type: application/pdf
Content-Disposition: file; filename="CustomerAgreement.pdf"; documentid="1"

PDF_BYTE_STREAM_HERE
--MY_BOUNDARY--

根据您张贴在你的问题的代码,我怀疑的是,错误是由一个事实,即在请求第二compositeTemplate对象不指定收件人而引起的。

最后,一些额外的评论:

  • 确保收件人信息(电子邮件,姓名,recipientId)你到底在所有复合模板对象指定的比赛。
  • 如果使用多请求创建信封(如图上面的例子),狠抓换行符 - 如图所示的例子,他们必须完全发生。
  • 虽然你可以使用一个多部分请求创建一个包含文件(S)的信封指定为请求的一部分(如上图所示的例子),一个更简单/简单的方式这样做是使用一个“正常”(即不是多部分)请求,从而只需将文档对象本身中指定的基64编码的文件字节,通过使用documentBase64属性-它消除了对多部分请求的需要。 见https://www.docusign.com/p/RESTAPIGuide/RESTAPIGuide.htm#REST API参考/文档Parameters.htm?高亮= documentbase64。


Answer 2:

我不知道这是否与您要提供inline文件。 我看到您指定的文件名,但没有documentId以及可能导致错误的,因为它可能默认为documentId = 1 ,这是最有可能在服务器模板文件的使用。

尝试是这样的:

"document": {
    "name": "body.pdf",
    "documentId": "2"
}


文章来源: getting unspecified error in docusign API while using COMPOSITE template