Server side template is replaced with uploaded document

Deadly 提交于 2019-12-25 02:27:06

问题


I'm am trying to create an envelope for embedded signing with two sever-side templates and a pdf document I generated all in one request. One of the server-side templates has a DOB tab that will be filled in with the data specified in the request.

I've reviewed some other questions related to the docusign api and composite templates with documents here and here I've used these examples to format my request.

Here is the request: NOTE: I'm using the multipart-post gem here to create the request, so some of this request is pseudo HTTP with some multipart-post info. I'm not sure how to get a fully formed HTTP request out in order to post it here.

POST http://localhost/restapi/v2/accounts/2/envelopes
X-DocuSign-Authentication: [omitted]

-------------RubyMultipartPost
Content-Type: application/json
Content-Disposition: form-data;
name="post_body"
{
"compositeTemplates": [
    {
        "serverTemplates": [
            {
                "sequence": 1,
                "templateId": "3093E017-2E18-4A30-A104-0201C601CE5F"
            }
        ],
        "inlineTemplates": [
            {
                "sequence": 1,
                "recipients": {
                    "signers": [
                        {
                            "email": "jond@gmail.com",
                            "name": "Jon D. Doe",
                            "recipientId": "1",
                            "roleName": "Proposed Insured",
                            "clientUserId": "jond@gmail.com",
                            "tabs": {
                                "textTabs": [

                                ],
                                "checkboxTabs": [

                                ],
                                "fullNameTabs": [

                                ],
                                "dateTabs": [
                                    {
                                        "tabLabel": "DOB",
                                        "name": null,
                                        "value": "1-21-1974",
                                        "documentId": null,
                                        "selected": null
                                    }
                                ]
                            }
                        }
                    ]
                }
            }
        ],
        "document": {
            "documentId": "1",
            "name": "test.pdf"
        }
    },
    {
        "serverTemplates": [
            {
                "sequence": 2,
                "templateId": "63CA2E24-BBB8-499F-A884-021580DF54AF"
            }
        ],
        "inlineTemplates": [
            {
                "sequence": 2,
                "recipients": {
                    "signers": [
                        {
                            "email": "jond@gmail.com",
                            "name": "Jon D. Doe",
                            "recipientId": "1",
                            "roleName": "Proposed Insured",
                            "clientUserId": "jond@gmail.com",
                            "tabs": {
                                "textTabs": [

                                ],
                                "checkboxTabs": [

                                ],
                                "fullNameTabs": [

                                ],
                                "dateTabs": [
                                    {
                                        "tabLabel": "DOB",
                                        "name": null,
                                        "value": "1-21-1974",
                                        "documentId": null,
                                        "selected": null
                                    }
                                ]
                            }
                        }
                    ]
                }
            }
        ]
    }
],
"status": "sent"
}
-------------RubyMultipartPost
Content-Disposition: file;filename="test.pdf";documentid=1;name="file1"
Content-Length: 34967
Content-Type: application/pdf
Content-Transfer-Encoding: binary

[pdf bytes omitted]

The resulting embedded view only has two documents in it. The 1st is the test.pdf I uploaded in the request and the 2nd is the server-side template specified by templateId=63CA2E24-BBB8-499F-A884-021580DF54AF

I'm not sure what I'm doing wrong .. according to the other questions I referenced above, this should work.


回答1:


Each compositeTemplate object can only supply files from a single source -- and if a compositeTemplate object specifies a document, then that's considered the document source for that compositeTemplate object. In that case, any documents that happen to be part of a serverTemplate within the same compositeTemplate object will be ignored. This seems to be what you're experiencing.

The request you posted only contains two compositeTemplate objects, so the resulting Envelope only contains documents from two document sources:

  • The document that's specified in the first compositeTemplate object.

  • The file(s) contained in the serverTemplate that's specified in the second compositeTemplate object.

If you want the Envelope to also contain the file(s) contained in serverTemplate 3093E017-2E18-4A30-A104-0201C601CE5F, you'll need to add a third compositeTemplate object to the request that specifies 3093E017-2E18-4A30-A104-0201C601CE5F as the server template, and uses the inlineTemplate info to provide necessary recipient and tab information (as you've done with the other compositeTemplate objects in the request you posted). [See below for full request example.]

Finally, note that the value of the sequence properties within each compositeTemplate object specify the order in which the serverTemplates and inlineTemplates will be applied within the scope of that specific compositeTemplate -- it does nothing to influence the sequence of documents in the Envelope. It's the order of the compositeTemplate objects in the request JSON/XML itself that determines sequence of documents in the resulting Envelope.

The following request will result in an Envelope that contains the following files (in this order):

  1. Files from template 3093E017-2E18-4A30-A104-0201C601CE5F
  2. The document that's specified by the request (documentId=1)
  3. Files from template 63CA2E24-BBB8-499F-A884-021580DF54AF

Request body (JSON part):

{
    "compositeTemplates": [
        {
            "serverTemplates": [
                {
                    "sequence": 1,
                    "templateId": "3093E017-2E18-4A30-A104-0201C601CE5F"
                }
            ],
            "inlineTemplates": [
                {
                    "sequence": 2,
                    "recipients": {
                        "signers": [
                            {
                                "email": "jond@gmail.com",
                                "name": "Jon D. Doe",
                                "recipientId": "1",
                                "roleName": "Proposed Insured",
                                "clientUserId": "jond@gmail.com",
                                "tabs": {
                                    "dateTabs": [
                                        {
                                            "tabLabel": "DOB",
                                            "name": null,
                                            "value": "1-21-1974",
                                            "documentId": null,
                                            "selected": null
                                        }
                                    ]
                                }
                            }
                        ]
                    }
                }
            ]
        },
        {
            "serverTemplates": [
                {
                    "sequence": 1,
                    "templateId": "3093E017-2E18-4A30-A104-0201C601CE5F"
                }
            ],
            "inlineTemplates": [
                {
                    "sequence": 2,
                    "recipients": {
                        "signers": [
                            {
                                "email": "jond@gmail.com",
                                "name": "Jon D. Doe",
                                "recipientId": "1",
                                "roleName": "Proposed Insured",
                                "clientUserId": "jond@gmail.com",
                                "tabs": {
                                    "dateTabs": [
                                        {
                                            "tabLabel": "DOB",
                                            "name": null,
                                            "value": "1-21-1974",
                                            "documentId": null,
                                            "selected": null
                                        }
                                    ]
                                }
                            }
                        ]
                    }
                }
            ],
            "document": {
                "documentId": "1",
                "name": "test.pdf"
            }
        },
        {
            "serverTemplates": [
                {
                    "sequence": 1,
                    "templateId": "63CA2E24-BBB8-499F-A884-021580DF54AF"
                }
            ],
            "inlineTemplates": [
                {
                    "sequence": 2,
                    "recipients": {
                        "signers": [
                            {
                                "email": "jond@gmail.com",
                                "name": "Jon D. Doe",
                                "recipientId": "1",
                                "roleName": "Proposed Insured",
                                "clientUserId": "jond@gmail.com",
                                "tabs": {
                                    "dateTabs": [
                                        {
                                            "tabLabel": "DOB",
                                            "name": null,
                                            "value": "1-21-1974",
                                            "documentId": null,
                                            "selected": null
                                        }
                                    ]
                                }
                            }
                        ]
                    }
                }
            ]
        }
    ],
    "status": "sent"
}


来源:https://stackoverflow.com/questions/24965892/server-side-template-is-replaced-with-uploaded-document

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!