使用COMPOSITE模板时,在docusign API中得到未指定的错误 [英] getting unspecified error in docusign API while using COMPOSITE template

查看:50
本文介绍了使用COMPOSITE模板时,在docusign API中得到未指定的错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

Hi I am trying to use COMPOSITE template to club one template and add a document while creating envelope.

完整的请求如下。

但是我得到如下 UNSPECIFIED_ERROR

However i am getting "UNSPECIFIED_ERROR" as below

我是新使用docusign和复合模板API的人。

I am new to use docusign and composite template API.

如果在我参考了有关复合模板的在线材料后尝试了该请求,那么有人可以指出我的错误就很好了。

It would be great if someone can point me the error as i tried the request after referring to online material about composite templates.

感谢阅读!!!

响应:

{
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--


推荐答案

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

Each individual compositeTemplate object in the request must specify both:


  • 文档-通过定义serverTemplate 或通过请求中指定的独立
    文档

  • document(s) -- either defined via serverTemplate(s) or via standalone document that's specified as part of the request

AND


  • 收件人

例如,以下多部分请求将创建一个信封,其中包含服务器模板中的文档,后跟请求中指定的其他文档:

For example, the following multipart request will create an Envelope that contains the documents from the server Template, followed by the additional document that's specified in the request:

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 对象的顺序,以便在服务器模板之前指定该文档:

If I wanted the additional document to appear first in the envelope, I would simply swap the order of compositeTemplate objects in the request, so that the document is specified before the server template:

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 对象未指定收件人而引起的。

Based on the code you've posted in your question, I'd suspect that the error is being caused by the fact that the second compositeTemplate object in the request does not specify recipients.

最后,再加上一些其他评论:

Finally, a few additional comments:


  • 请确保收件人信息(电子邮件,您指定的名称,收件人ID)在所有组合模板对象中完全匹配。

  • 如果您使用多部分请求来创建信封(如上述示例所示),请特别注意换行符-它们必须完全按照示例所示进行。

  • 尽管您可以使用多部分请求创建一个信封,其中包含您指定为请求的一部分(如上面的示例所示),一种更简单的方法是使用正常(即不是多部分)请求,您只需指定通过使用 documentBase64 属性,在 document 对象本身中确定 base-64编码 文档字节消除了对多部分请求的需求。请参阅 https://www.docusign.com/p/RESTAPIGuide/RESTAPIGuide.htm# REST API参考/文档Parameters.htm?Highlight = documentbase64。

  • Make sure that the recipient info (email, name, recipientId) you specify matches exactly across all composite template objects.
  • If you use a multipart request to create the envelope (as shown in the above examples), pay close attention to line breaks -- they must occur exactly as shown in the examples.
  • Although you can use a multipart request to create an envelope that contains document(s) you specify as part of the request (as the examples above show), an easier/simpler way to do so would be to use a "normal" (i.e., not multi-part) request whereby you simply specify base-64-encoded document bytes within the document object itself, by using the documentBase64 property -- which eliminates the need for the multipart request. See https://www.docusign.com/p/RESTAPIGuide/RESTAPIGuide.htm#REST API References/Document Parameters.htm?Highlight=documentbase64.

这篇关于使用COMPOSITE模板时,在docusign API中得到未指定的错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆