Docusign composite template giving TAB_REFERS_TO_MISSING_DOCUMENT - docusignapi

I was trying to use these two templates as a composite template thru the REST api. I sent out each template on its own and it worked fine. Here is the request from the log file:
Content-Length: 1526
Host: demo.docusign.net
X-DocuSign-Authentication: {"Username":"Kathleen.Jones#XXX.com","Password":"[omitted]","IntegratorKey":"[omitted]"}
X-Forwarded-For: 63.118.233.100, 104.129.194.117
{
"compositeTemplates": [
{
"serverTemplates": [
{
"sequence": "1",
"templateId": "2d743750-f910-4a30-ad34-ac5bc0ca8daa"
},
{
"sequence": "2",
"templateId": "63479d79-a776-4767-a2a3-1ebd01d7d8fa "
}
],
"inlineTemplates": [
{
"sequence": "1",
"recipients": {
"signers": [
{
"name": "Joe Blow",
"email": "JoeBlow#outlook.com",
"recipientId": "1",
"roleName": "CEO"
},
{
"name": "Kathy Blow",
"email": "KathyBlow#outlook.com",
"recipientId": "2",
"roleName": "Uber CEO"
}
]
}
},
{
"sequence": "2",
"recipients": {
"signers": [
{
"name": "Joe Blow",
"email": "JoeBloww#outlook.com",
"recipientId": "2",
"roleName": "Uber CEO"
},
{
"name": "Kathy Blow",
"email": "KathyBlow#outlook.com",
"recipientId": "1",
"roleName": "CEO"
}
]
}
}
]
}
],
"status": "sent",
"emailSubject": "Please Sign the enclosed docs at your earliest convenience"
}
400 BadRequest
Content-Type: application/json; charset=utf-8
X-DocuSign-TraceToken: cb23f0ed-6be2-4189-9237-5575671f8f4b
{
"errorCode": "TAB_REFERS_TO_MISSING_DOCUMENT",
"message": "The DocumentId specified in the tab element does not refer to a document in this envelope. Tab refers to DocumentId 15100956 which is not present."
}
Like I said, I used the 2 templates standalone and they went out fine. Any ideas?

I found the answer right here in a StackOverflow answer:
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.

Related

DocuSign Envelope creation failed containing PDF fields transformation

This is my JSON code so far:
{
"status": "sent",
"emailSubject": "This is an api Demo Doc, sent for signature",
"recipients": {
"carbonCopies": [
{
"email": "nila#gmail.com",
"name": "Nilashree",
"recipientId": "2"
}
],
"signers": [
{
"email": "{{signer1Email}}",
"name": "Nilashree Nandkumar shirodkar",
"recipientId": "1"
}
]
},
"compositeTemplates": [
{
"inlineTemplates": [
{
"sequence": "1",
"recipients": {
"signers": [
{
"email": "nshiro2#students.towson.edu",
"name": "Nila Joseph",
"recipientId": "1",
"defaultRecipient": "true"
}
]
}
}
],
"documents": {
"documentId": "1",
"name": "application_form.pdf",
"transformPdfFields": "true",
"documentBase64": "{{}}"
}
}
]
}
But I am getting the following error:
"errorCode": "ENVELOPE_IS_INCOMPLETE",
"message": "The Envelope is not Complete. A Complete Envelope Requires Documents, Recipients, Tabs, and a Subject Line."
Can anyone please let me know what am I doing wrong?
Why are you using a composite template? Perhaps you are planning towards a later, more complicated envelope definition.
Your mistake is that each composite template can optionally contain only one document. The field name is document, not documents.
Instead of
"documents": {
"documentId": "1",
"name": "application_form.pdf",
"transformPdfFields": "true",
"documentBase64": "{{}}"
}
use
"document": {
"documentId": "1",
"name": "application_form.pdf",
"transformPdfFields": "true",
"documentBase64": "{{}}"
}
Also, I don't believe there's a need for the recipients outside of the composite templates structure. I'm not 100% sure about this issue though.

Docusign createEnvelope REST API with Composite Templates CANNOT_EXCLUDE_DOCUMENT Error

Using documentation at createEnvelope with composite templates
https://docs.docusign.com/esign/restapi/Envelopes/Envelopes/create/
https://developers.docusign.com/esign-rest-api/guides/features/templates
When we attempt to use this API for multiple templates we are getting error similar to below
{\r\n \"errorCode\": \"CANNOT_EXCLUDE_DOCUMENT\",\r\n \"message\": \"This document cannot be excluded for this recipient. Recipient: Enbmgr Enbmgr cannot be excluded from Document:TalentEmploymentAgreemt_0617AqVT.pdf\"\r\n}"}}
When the sequence of the templates are changed it works fine. What could be the cause for this?
The account is set up with Document Visibity: Sender can set "must sign to view unless sender"
Error when sent with below sequence:
Templateid- f09dc354-efd6-437e-9410-5270b181a1f1 Roles: Emp, Mgr (sign in sequence enabled)
Templateid- 8c919c05-ee1f-42c4-b521-861c5f2949b Roles: Emp
Templateid- 6b57ea78-5923-4c54-b4c1-15c8d5313e71 Roles: Emp, Mgr (sign in sequence enabled)
Success when sent with below sequence:
Templateid- 6b57ea78-5923-4c54-b4c1-15c8d5313e71 Roles: Emp, Mgr (sign in sequence enabled)
Templateid- f09dc354-efd6-437e-9410-5270b181a1f1 Roles: Emp, Mgr (sign in sequence enabled)
Templateid- 8c919c05-ee1f-42c4-b521-861c5f2949b Roles: Emp
Request giving error:
{
"emailSubject": "DocuSign API - Composite Templates",
"emailBlurb": "Composite Templates Sample 1",
"status": "sent",
"compositeTemplates": [
{
"serverTemplates": [
{
"sequence": "1",
"templateId": "f09dc354-efd6-437e-9410-5270b181a1f1"
}
],
"inlineTemplates": [
{
"sequence": "2",
"recipients": {
"signers": [
{
"email": "ranjesh+emp#enboarder.com",
"name": "Enbemp Enbemp",
"roleName": "Talent",
"recipientId": "1",
"tabs": {}
},
{
"email": "ranjesh+mgr#enboarder.com",
"name": "Enbmgr Enbmgr",
"roleName": "OM",
"recipientId": "2",
"tabs": {}
}
]
}
}
]
},
{
"serverTemplates": [
{
"sequence": "3",
"templateId": "8c919c05-ee1f-42c4-b521-861c5f2949bf"
}
],
"inlineTemplates": [
{
"sequence": "4",
"recipients": {
"signers": [
{
"email": "ranjesh+emp#enboarder.com",
"name": "Enbemp Enbemp",
"roleName": "Talent",
"recipientId": "1",
"tabs": {
"textTabs": [
{
"tabLabel": "\\*Market",
"value": " "
}
]
}
}
]
}
}
]
},
{
"serverTemplates": [
{
"sequence": "5",
"templateId": "6b57ea78-5923-4c54-b4c1-15c8d5313e71"
}
],
"inlineTemplates": [
{
"sequence": "6",
"recipients": {
"signers": [
{
"email": "ranjesh+emp#enboarder.com",
"name": "Enbemp Enbemp",
"roleName": "Talent",
"recipientId": "1",
"tabs": {}
},
{
"email": "ranjesh+mgr#enboarder.com",
"name": "Enbmgr Enbmgr",
"roleName": "OM",
"recipientId": "2",
"tabs": {}
}
]
}
}
]
}
]
}
Request giving success:
{
"emailSubject": "DocuSign API - Composite Templates",
"emailBlurb": "Composite Templates Sample 1",
"status": "sent",
"compositeTemplates": [
{
"serverTemplates": [
{
"sequence": "1",
"templateId": "6b57ea78-5923-4c54-b4c1-15c8d5313e71"
}
],
"inlineTemplates": [
{
"sequence": "2",
"recipients": {
"signers": [
{
"email": "ranjesh+emp#enboarder.com",
"name": "Enbemp Enbemp",
"roleName": "Talent",
"recipientId": "1",
"tabs": {}
},
{
"email": "ranjesh+mgr#enboarder.com",
"name": "Enbmgr Enbmgr",
"roleName": "OM",
"recipientId": "2",
"tabs": {}
}
]
}
}
]
},
{
"serverTemplates": [
{
"sequence": "3",
"templateId": "f09dc354-efd6-437e-9410-5270b181a1f1"
}
],
"inlineTemplates": [
{
"sequence": "4",
"recipients": {
"signers": [
{
"email": "ranjesh+emp#enboarder.com",
"name": "Enbemp Enbemp",
"roleName": "Talent",
"recipientId": "1",
"tabs": {}
},
{
"email": "ranjesh+mgr#enboarder.com",
"name": "Enbmgr Enbmgr",
"roleName": "OM",
"recipientId": "2",
"tabs": {}
}
]
}
}
]
},
{
"serverTemplates": [
{
"sequence": "5",
"templateId": "8c919c05-ee1f-42c4-b521-861c5f2949bf"
}
],
"inlineTemplates": [
{
"sequence": "6",
"recipients": {
"signers": [
{
"email": "ranjesh+emp#enboarder.com",
"name": "Enbemp Enbemp",
"roleName": "Talent",
"recipientId": "1",
"tabs": {
"textTabs": [
{
"tabLabel": "\\*Market",
"value": " "
}
]
}
}
]
}
}
]
}
]
}
I've found that the last template looks like this
Template definition with excluded documents for a signer
How are excluded documents for signers setup in Docusign's application?
I suspect how the Roles and Tabs are distributed matters, yet I can't see your template or the API Json sent.
You can get the API log capture of the exact JSON/SOAP request posted by your API calls via Java to DocuSign by following steps explained at this DocuSign support article https://support.docusign.com/guides/ndse-user-guide-api-request-logging
Here is part of what you need to understand about Sequence numbers and physical order - In composite templates, physical order overrules the "index/sequence" per composite template node. The index is the internal glue, but not really the row order in the in-memory model. I suspect you really wanted to restart the sequence number in each node of "composite template" since you are saying I have "three" documents and x number of features and roles per document as both working and not working collapse to the following structure composite nodes structure except it looks like you had (corrected now) an extra "[" array grouping:
(corrected now in updated question)
"compositeTemplates": [{
"serverTemplates": [{
"inlineTemplates": [{
"document": ....
or to match yours:
"compositeTemplates": [
{},
{},
{}
]
This all supposes you want three documents, if you want one document, then you keep the server templates in the same array collection inside the composite node to be applied to the contributing document, one with the lowest sequence number. Remember in JSON/REST if the JSON is malformed aka includes more than needed, the API just ignores it as "client comments" and takes what it can use.
The lower the sequence: document node (not documents) between server, inline and document being 0 is how the "PDF/DOC bytes are determined, and the higher the sequence number the feature that wins aka doc vis in one template, vs another or the notification days number.
I will have to probably wait for the logs, however I think the clue to the issue on doc vis error is the "tabLabel": "\*Market" which goes from middle to last between the two examples. Anchor strings are envelope wide, so I suspect it "meets" the needed criteria for the feature for that role which is probably required per the template. You can put the all the roles in the last composite template node of the last inline template node and it will apply them to all the previous composite template nodes where they are not supplied by an inline template.
So there is a best practice document I am about to publish explaining this on complex template assembly in envelopes, however, hope this helps for now.
Please attach your logs so we can see the real example and determine which played into the results you are describing.

Docusign: composite templates with tabs

How do I specify prefilled fields with composite templates when creating an envelope.
I tried including the tabs information in the inlineTemplate.recipients.signers[0].tabs, but I get an error that System.String cannot be cast to API_REST.Models.v2.tabs.
If I include information as a template role in templateRoles, it is ignored. The documentation is light on information about how to do this. It seems like the prefill data should be specified in the inline template.
Other open questions I have include what does the recipientId do. What is the clientUserIdused for? We currently set clientUserId to the same value for all signers. I see it's used when signer requests a signature. Should it be unique to every signer for some reason?
It also looks like a single composite template overlays the server and inline templates on top of each other. What's the use case for having multiple server templates or multiple inline templates in a single composite template?
Are there plans to improve the documentation to describe how to use composite templates for various purposes?
Signer/template role:
{
"clientUserId": "clientUserId",
"email": "first+last#email.com",
"name": "First Last",
"roleName": "role1",
"tabs": {
"textTabs": [
{
"locked": true,
"tabLabel": "\\*FieldName",
"value": "prefillValue"
}
]
}
}
Example request:
{
"compositeTemplates": [
{
"inlineTemplates": [
{
"recipients": {
"signers": [
{
"clientUserId": "clientUserId",
"email": "first+last#email.com",
"name": "First Last",
"recipientId": 1,
"roleName": "role1",
"tabs": {
"textTabs": [{"tabLabel": "label", "value": "val"}]
}
}
]
},
"sequence": 1
}
],
"serverTemplates": [
{
"sequence": 1,
"templateId": "templateId1"
}
]
},
{
"inlineTemplates": [
{
"recipients": {
"signers": [
{
"clientUserId": "clientUserId",
"email": "first+last#better.com",
"name": "First Last",
"recipientId": 1,
"roleName": "role1",
"tabs": {
"textTabs": [{"tabLabel": "label", "value": "val"}]
}
}
]
},
"sequence": 2
}
],
"serverTemplates": [
{
"sequence": 2,
"templateId": "templateId2"
}
]
}
],
"emailSubject": "Email subject",
"status": "sent",
"templateId": null,
"templateRoles": null
}
Information on sending an envelope from a server template can be found here.
RecipientID is used by the tab element to indicate which recipient is to sign the Document while the clientuserID specifies if the user is remote or embedded and it is recommended it be unique per signer (but not required).
I'd also suggest reading this page about composite templates, hopefully the concept will make a bit more sense but I am with you that the lack of documentation on composite templates can be troublesome.
Unfortunately, I don't have a sample with tab data included, but adding the tab section under each recipient from my sample below should work with no issues.
{
"emailSubject": "DocuSign Comp Test 1",
"emailBlurb": "Example - Composite Templates",
"status": "sent",
"compositeTemplates": [
{
"serverTemplates": [
{
"sequence": "1",
"templateId": "templateId1"
}
],
"inlineTemplates": [
{
"sequence": "1",
"recipients": {
"signers": [
{
"email": "testsigner123#gmail.com",
"name": "Test Tester",
"recipientId": "1",
"roleName": "Signer 1"
}
]
}
}
]
},
{
"serverTemplates": [
{
"sequence": "2",
"templateId": "templateId2"
}
],
"inlineTemplates": [
{
"sequence": "2",
"recipients": {
"signers": [
{
"email": "testsigner123#gmail.com",
"name": "Test Tester",
"recipientId": "1",
"roleName": "Signer 1"
}
]
}
}
]
},
{
"serverTemplates": [
{
"sequence": "3",
"templateId": "templateId3"
}
],
"inlineTemplates": [
{
"sequence": "2",
"recipients": {
"signers": [
{
"email": "testsigner123#gmail.com",
"name": "Test Tester",
"recipientId": "1",
"roleName": "Signer 1"
}
]
}
}
]
}
]
}

Attempting to provide a document to override a server template causes Unspecified error An item with the same key has already been added

I'm attempting to port code that uses the Docusign SOAP API method CreateEnvelopeFromTemplatesAndForms to the REST API. I used this page of the Rest API Reference - Send an Envelope from a Template
I've hit a roadblock in that when I try to specify a document to post to override the server template's document, I get an Unspecified error, 'An item with the same key has already been added'.
The code I'm porting over uses two inline templates and a server template.
The server template can contain one or more documents that I want to override with local documents. In the SOAP method, the documents are specified in the first inline template. The server template is specified next. And the second inline template is third in the sequence and has the recipients and custom fields. These are all added to the envelope property of the inline template.
Inline Template - Docs
Server Template
Inline Template - Recipients and Custom Fields
In the REST api, there doesn't seem to be an envelope property for the inline template and no clear migration guide between SOAP and REST that I could find. If I exclude my 'documents' property from the inline template, the envelope sends. I get the same error if I try using the document property of compositeTemplate. Here is my web request:
POST https://demo.docusign.net/restapi/v2/accounts/ACCOUNTID/envelopes HTTP/1.1
X-DocuSign-Authentication: <DocuSignCredentials><Username>USERNAME</Username><Password>PASSWORD</Password><IntegratorKey>INTEGRATOR_KEY</IntegratorKey></DocuSignCredentials>
Accept: application/json
Content-Type: multipart/form-data; boundary=Ne737Hao~j
Host: demo.docusign.net
Content-Length: 29110
Expect: 100-continue
--Ne737Hao~j
Content-Type: application/json
Content-Disposition: form-data
{
"status": "sent",
"emailSubject": "Test Doc",
"emailBlurb": "This is a test doc",
"compositeTemplates": [
{
"serverTemplates": [
{
"sequence": "2",
"templateId": "0b9f2226-6c2b-4c75-84c4-c1708a5c7b97"
}
],
"inlineTemplates": [
{
"sequence": "1",
"documents": [
{
"documentId": "1",
"name": "Donuts.pdf",
"transformPdfFields": "false"
}
]
},
{
"sequence": "3",
"recipients": {
"signers": [
{
"name": "ME",
"recipientId": "99f8f51b-ef21-46b6-a551-69c8b27159d4",
"roleName": "Signer 1",
"email": "MY_EMAIL_ADDRESS"
},
{
"name": "ME",
"recipientId": "bb4388f3-098e-4d3e-bcf2-20c1ae0a7c48",
"roleName": "Signer 2",
"email": "MY_EMAIL_ADDRESS"
}
],
"carbonCopies": [
{
"name": "ME",
"recipientId": "bc65de08-984e-4f95-925d-fcf00c05966d",
"roleName": "Auditor",
"email": "MY_EMAIL_ADDRESS"
}
]
}
}
]
}
],
"customFields": {
"textCustomFields": [
{
"name": "TemplateName",
"show": "false",
"value": "Test Template"
}
]
}
}
--Ne737Hao~j
Content-Type: application/pdf
Content-Disposition:file; file="Donuts.pdf"; documentId=1
Content-Transfer-Encoding: binary
%PDF-1.6
REST OF PDF BYTES
%%EOF
--Ne737Hao~j--
Thanks in advance.
I've also already looked at Incorrectly applied server templates with multiple composite templates and Adding documents to envelopes using composite templates in DocuSign with little luck.
Update
After trying the answer by WTP API below, I experimented some more. I found that the envelope would send with the correct document if I either include the base64 of the document or if I simplified the headers sent with the document bytes to just be Content-Disposition:documentId=1 instead of all the headers shown here: Docusign Rest API - Send an Envelope From a Template
POST https://demo.docusign.net/restapi/v2/accounts/ACCOUNTID/envelopes HTTP/1.1
X-DocuSign-Authentication: <DocuSignCredentials><Username>USERNAME</Username><Password>PASSWORD</Password><IntegratorKey>INTEGRATOR_KEY</IntegratorKey></DocuSignCredentials>
Accept: application/json
Content-Type: multipart/form-data; boundary=Ne737Hao~j
Host: demo.docusign.net
Content-Length: 29110
Expect: 100-continue
--Ne737Hao~j
Content-Type: application/json
Content-Disposition: form-data
{
"status": "sent",
"emailSubject": "Test Doc",
"emailBlurb": "This is a test doc",
"compositeTemplates": [
{
"serverTemplates": [
{
"sequence": "2",
"templateId": "0b9f2226-6c2b-4c75-84c4-c1708a5c7b97"
}
],
"inlineTemplates": [
{
"sequence": "1",
"documents": [
{
"documentId": "1",
"name": "Donuts.pdf",
"transformPdfFields": "false"
}
]
},
{
"sequence": "3",
"recipients": {
"signers": [
{
"name": "ME",
"recipientId": "99f8f51b-ef21-46b6-a551-69c8b27159d4",
"roleName": "Signer 1",
"email": "MY_EMAIL_ADDRESS"
},
{
"name": "ME",
"recipientId": "bb4388f3-098e-4d3e-bcf2-20c1ae0a7c48",
"roleName": "Signer 2",
"email": "MY_EMAIL_ADDRESS"
}
],
"carbonCopies": [
{
"name": "ME",
"recipientId": "bc65de08-984e-4f95-925d-fcf00c05966d",
"roleName": "Auditor",
"email": "MY_EMAIL_ADDRESS"
}
]
}
}
]
}
],
"customFields": {
"textCustomFields": [
{
"name": "TemplateName",
"show": "false",
"value": "Test Template"
}
]
}
}
--Ne737Hao~j
Content-Disposition:documentId=1
%PDF-1.6
REST OF PDF BYTES
%%EOF
--Ne737Hao~j--
The "documents" node and "recipients" should be within the same inline template.
Below is the correct JSON body that works for me:
{
"status": "sent",
"emailSubject": "Test Doc",
"emailBlurb": "This is a test doc",
"compositeTemplates": [
{
"serverTemplates": [
{
"sequence": "2",
"templateId": "0b9f2226-6c2b-4c75-84c4-c1708a5c7b97"
}
],
"inlineTemplates": [
{
"sequence": "1",
"documents": [
{
"documentId": "1",
"name": "Donuts.pdf",
"transformPdfFields": "false"
}
],
"recipients": {
"signers": [
{
"name": "ME",
"recipientId": "99f8f51b-ef21-46b6-a551-69c8b27159d4",
"roleName": "Signer 1",
"email": "MY_EMAIL_ADDRESS"
},
{
"name": "ME",
"recipientId": "bb4388f3-098e-4d3e-bcf2-20c1ae0a7c48",
"roleName": "Signer 2",
"email": "MY_EMAIL_ADDRESS"
}
],
"carbonCopies": [
{
"name": "ME",
"recipientId": "bc65de08-984e-4f95-925d-fcf00c05966d",
"roleName": "Auditor",
"email": "MY_EMAIL_ADDRESS"
}
]
}
}
]
}
],
"customFields": {
"textCustomFields": [
{
"name": "TemplateName",
"show": "false",
"value": "Test Template"
}
]
}
}

Adding documents to envelopes using composite templates in DocuSign

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?
Thank you in advance!
UPDATE:
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--
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.
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"
}
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.
RE the "UPDATE" to your question:
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--

Resources