0

您好我正在尝试使用 COMPOSITE 模板来组合一个模板并在创建信封时添加一个文档。

完整的请求如下。

但是我收到“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--
4

2 回答 2

2

请求中的每个单独的复合模板对象必须同时指定:

  • document(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对象未指定收件人这一事实引起的。

最后,补充几点意见:

  • 确保您指定的收件人信息(电子邮件、姓名、收件人 ID)在所有复合模板对象中完全匹配。
  • 如果您使用多部分请求来创建信封(如上面的示例所示),请密切注意换行符——它们必须完全按照示例中所示出现。
  • 尽管您可以使用多部分请求来创建包含您指定为请求一部分的文档的信封(如上面的示例所示),但更简单/更简单的方法是使用“正常”(即,而不是多部分)请求,您只需使用documentBase64属性在文档对象本身内指定base-64 编码的文档字节- 这消除了对多部分请求的需要。请参阅https://www.docusign.com/p/RESTAPIGuide/RESTAPIGuide.htm#REST API 参考/文档参数.htm?Highlight=documentbase64。
于 2014-05-12T15:14:11.643 回答
1

我想知道这是否与您提供的内联文档有关。我看到您指定了文档名称但没有指定documentId,这可能会导致错误,因为它可能默认为documentId= 1,这很可能被服务器模板文档使用。

尝试这样的事情:

"document": {
    "name": "body.pdf",
    "documentId": "2"
}
于 2014-05-10T15:23:13.943 回答