在DocuSign中使用复合模板将文档添加到信封 [英] Adding documents to envelopes using composite templates in DocuSign

查看:59
本文介绍了在DocuSign中使用复合模板将文档添加到信封的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用docusign api将文档添加到复合模板中,并且文档没有按照我期望的方式加载到信封中。目前,我的代码与测试json一起使用,在其中我无需使用复合模板即可添加文档,并且效果很好。似乎复合模板会跳过文档。这是我的创建方式:

I'm trying to add documents to a composite template using the docusign api and the documents aren't loading into the envelope the way I would expect it to. I currently have my code working with a test json where I add documents without using composite templates and it works perfectly. It seems the composite templates skip right over the documents however. Here's how I'm creating it:

{
"emailSubject": "Test Email Subject_FA",
"emailBlurb": "Test Email Body_FA",
"status": "created",
"compositeTemplates": [
    {
        "inlineTemplates": [
            {
                "sequence": "1",
                "recipients": {
                    "signers": [
                        {
                            "email": "test1@yahoo.com",
                            "name": "test1",
                            "recipientId": "1",
                            "routingOrder": "1",
                            "roleName": "Client 1"
                        },
                        {
                            "email": "test2@gmail.com",
                            "name": "test2",
                            "recipientId": "2",
                            "routingOrder": "2",
                            "roleName": "Client 2"
                        }
                    ],
                    "documents": [
                        {
                            "transformPdfFields": "false",
                            "name": "test0.pdf",
                            "documentId": "1"
                        }
                    ]
                }
            }
        ]
    },
    {
        "inlineTemplates": [
            {
                "sequence": "1",
                "recipients": {
                    "signers": [
                        {
                            "email": "test1@yahoo.com",
                            "name": "test1",
                            "recipientId": "1",
                            "routingOrder": "1",
                            "roleName": "Client 1"
                        },
                        {
                            "email": "test2@gmail.com",
                            "name": "test2",
                            "recipientId": "2",
                            "routingOrder": "2",
                            "roleName": "Client 2"
                        }
                    ],
                    "documents": [
                        {
                            "transformPdfFields": "false",
                            "name": "test1.pdf",
                            "documentId": "2"
                        }
                    ]
                }
            }
        ]
    }
]

}

这是我正在做的一点测试,所以我知道这是不切实际的。但是我想了解的是为什么它不会在信封中添加文档。下面的请求执行了我上面想要做的事情。

This is a little test I'm doing so I understand this is impractical. But what I'm trying to understand is why this wouldn't add documents to the envelope. The request below does what I'm trying to do above.

{
"emailSubject": "Test Email Subject_FA",
"emailBlurb": "Test Email Body_FA",
"status": "created",
"documents": [
    {
        "name": "test0.pdf",
        "documentId": "1"
    },
    {
        "name": "test1.pdf",
        "documentId": "2"
    },
    {
        "name": "test2.pdf",
        "documentId": "3"
    }
],
"recipients": {
    "signers": [
        {
            "email": "test1@yahoo.com",
            "name": "test1",
            "recipientId": "1",
            "clientUserId": "1",
            "signerName": "test1",
            "defaultRecipient": "true",
            "defaultRecipientSpecified": "true",
            "routingOrder": "1"
        },
        {
            "email": "test2@gmail.com",
            "name": "test2",
            "recipientId": "2",
            "clientUserId": "2",
            "signerName": "test2",
            "routingOrder": "2"
        }
    ]
}

}

有人知道为什么我的复合模板信封无法加载文档吗?

Does anybody know why my envelope for the composite template won't load the documents?

谢谢!

更新

这是我对复合模板的要求:

Here's my request for the composite template:

--MY_BOUNDARY
Content-Type: application/json
Content-Disposition: form-data
{                
"emailSubject": "Test Email Subject_FA",
"emailBlurb": "Test Email Body_FA",
"status" : "created",               
"compositeTemplates": [               
{                    
"inlineTemplates": [  
{ 
    "sequence": "1",    
    "recipients": 
    {                           
        "signers": [                              
        {                              
            "email": "test1@yahoo.com",    
            "name": "test1",             
            "recipientId": "1"                
        },                              
        {                              
            "email": "test2@gmail.com",  
            "name": "test2",         
            "recipientId": "2"              
        }                            
        ],                           
        "document":                  
        {                            
            "name": "test0",              
            "documentId": "1",            
            "fileExtension": "pdf"         
        }                               
    }                  
}                  
]               
},               
{                
"inlineTemplates": [   
{                     
    "sequence": "2",       
    "recipients": {         
    "signers": [            
        {                        
            "email": "test1@yahoo.com",   
            "name": "test1",          
            "recipientId": "1"
        },
        {                              
            "email": "test3@yahoo.com",  
            "name": "test3",                           
            "recipientId": "2"                               
        }
    ],                  
    "document":                                 
        {    
            "name": "test1",                             
            "documentId": "2",                           
            "fileExtension": "pdf"                       
        }                                             
    }                  
}                  
]               
}               
]           
}
--MY_BOUNDARY

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

--MY_BOUNDARY

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




--MY_BOUNDARY--

我已经调整了文档以使用名称和fileDxtension,因此我在fileName上省略了.pdf扩展名,因为这似乎是实现此目的的另一种方法。我已经尝试了两种方法,但是都没有运气。

I've adjusted my document to use name and fileDxtension, so I left out the .pdf extension on the fileName as that seems to be another method of implementing this. I've tried it both ways and had no luck.

推荐答案

在您发布的请求JSON中,您指定了 < strong> 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--

这篇关于在DocuSign中使用复合模板将文档添加到信封的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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