且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在DocuSign中使用复合模板将文档添加到信封

更新时间:2022-05-23 21:46:29

在您发布的请求JSON中,您指定了 documents (多个)作为 document 对象的集合/数组-这是不正确的。 compositeTemplates 数组中的每个Composite Template项目最多只能包含一个单个文档。这意味着用于在Composite Template中指定文档的JSON语法如下:

In the request JSON you posted, you're specifying "documents" (plural) as a collection/array of document objects -- which isn't correct. Each Composite Template item within the compositeTemplates array can only contain, at most, a single document. This means that the JSON syntax for specifying the document within a Composite Template is as follows:

"document": {
    "documentId": 1,
    "name": "test1.pdf"
}

文档是单数,它是一个对象(不是对象数组)。上一个问题的答案中显示了复合模板 JSON请求的完整请求语法:

如何使用Docusign REST API将模板应用于文档。

i.e., document is singular, and it's an object (not an array of objects). Full request syntax of the 'composite templates' JSON request is shown in the answer of your prior question:
How do I apply a template to a document using Docusign REST API.

对问题进行更新

在您发布的请求的JSON部分下, UPDATE,我注意到您在收件人对象(包含在 inlineTemplates 对象中)中包含了文档文档的正确位置。将您的JSON结构与以下(正确的)结构进行比较,并相应地调整您的请求。本质上,文档必须是 inlineTemplates 的同级文件-不在 inlineTemplates 之内。

In the JSON portion of the request that you've posted under "UPDATE", I notice that you have included document inside of the recipients object (which is contained within the inlineTemplates object) -- this is not the correct location for document. Compare your JSON structure closely with the following (correct) structure, and adjust your request accordingly. Essentially, document must be a peer of inlineTemplates -- not located within inlineTemplates.

POST https://demo.docusign.net/restapi/v2/accounts/ACCOUNTNBR/envelopes HTTP/1.1

X-DocuSign-Authentication: {"Username":"USERNAME","Password":"PASSWORD","IntegratorKey":"INTEGRATORKEY"}
Content-Type: multipart/form-data; boundary=MY_BOUNDARY
Accept: application/json
Host: demo.docusign.net
Content-Length: 162100

--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": "CustomerAgreement",
            "fileExtension": "pdf"
        }
    }]
}

--MY_BOUNDARY
Content-Type: application/pdf
Content-Disposition: file; filename="CustomerAgreement.pdf"; documentid="1"

    <document bytes removed>

--MY_BOUNDARY
Content-Type: application/pdf
Content-Disposition: file; filename="Invoice.pdf"; documentid="2"

    <document bytes removed>

--MY_BOUNDARY--