Hi I am trying to use COMPOSITE template to club one template and add a document while creating envelope.
The complete request is below.
However i am getting "UNSPECIFIED_ERROR" as below
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.
Thanks for reading!!!
RESPONSE:
{
errorCode: "UNSPECIFIED_ERROR"
message: "An item with the same key has already been added."
}
REQUEST
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--
Each individual compositeTemplate object in the request must specify both:
document(s) -- either defined via serverTemplate(s) or via standalone
document that's specified as part of the request
AND
recipients
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--
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--
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:
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.
I'm wondering if this is related to the inline document you're supplying. I see that you specify the document name but no documentId and that might be causing the error as it probably defaults to documentId = 1, which is most likely in use by the server template document.
Try something like this:
"document": {
"name": "body.pdf",
"documentId": "2"
}
Related
I have created a template via the DocuSign UI; that template contains some tabs for various roles.
I want to send a document via DocuSign REST API, in which the template (only the tabs e.g. signHere, initiateHere, Title etc) will apply.
I haven't added any recipient on the template. What I want to use from that template are only the tabs.
My JSON
{
"emailBlurb":"Test Email Body",
"emailSubject": "Test Email Subject",
"status" : "sent",
"compositeTemplates": [
{
"serverTemplates": [
{
"sequence" : 1,
"templateId": "c9e5adfa-d708-4467-a0ea-c615fa429a0f"
}],
"inlineTemplates": [
{
"sequence" : 2,
"recipients": {
"signers" : [{
"email": "nalam#relisource.com",
"name": "Noor",
"recipientId": "1",
"roleName": "Applicant"
}]
}
}],
"document": {
"documentId": 1,
"name": "test1.pdf",
"documentBase64":"Base64streamhere"
}
}]
}
It gives me the following error.
{
"errorCode": "INVALID_CONTENT_TYPE",
"message": "Content Type specified is not supported."
}
I am using POSTMAN. What is the problem here ?
Your documentBase64 attribute doesn't look right. Perhaps an error in copying it? Also, setting the fileExtension is highly recommended:
It should be
"document": {
...
"documentBase64": "Base64EncodedString",
"fileExtension": "pdf"
}
I suggest you use API request logging to see exactly what Postman is sending.
Template document substitution
If you're trying to substitute a document at runtime for the document in a server template, see the answers to this SO question for additional tips.
What you want here is the serverTemplate to be in sequence with the inlineTemplate so they need to have the same sequence number. Also you need another inline template to hold your document object. Something like this:
{
"emailBlurb":"Test Email Body",
"emailSubject": "Test Email Subject",
"status" : "sent",
"compositeTemplates": [
{
"serverTemplates": [
{
"sequence" : 1,
"templateId": "c9e5adfa-d708-4467-a0ea-c615fa429a0f"
}],
"inlineTemplates": [
{
"sequence" : 1,
"recipients": {
"signers" : [{
"email": "nalam#relisource.com",
"name": "Noor",
"recipientId": "1",
"roleName": "Applicant"
}]
}
}],
"inlineTemplates": [
{
"sequence" : 2
"document": {
"documentId": 1,
"name": "test1.pdf",
"documentBase64":"Base64streamhere"
}
}
}]
}
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.
Adding a compositeTemplateId, as in the following JSON, causes the following error:
{
errorCode: "ENVELOPE_IS_INCOMPLETE"
message: "The Envelope is not Complete. A Complete Envelope Requires Documents, Recipients, Tabs, and a Subject Line."
}
Removing the compositeTemplateId prevents the error, but I need the composite template id for other reasons.
{
"emailSubject": "Please Print, Complete and Sign Document",
"emailBlurb": "Please print and complete documents and sign on paper. ",
"status": "sent",
"compositeTemplates": [{
"compositeTemplateId": "1",
"inlineTemplates": [{
"sequence": "1",
"customFields": {
"textCustomFields": [{
"name": "MyOwnField",
"required": "true",
"show": "true",
"value": "MyValue"
}]
},
"recipients": {
"signers": [{
"requireSignOnPaper": "true",
"name": "Millard Fillmore",
"email": "dgilbert#firstallied.com",
"recipientId": "1",
"routingOrder": "1"
}]
}
}],
"document": {
"documentId": "1",
"name": "Corestone Account Application.pdf",
"transformPdfFields": false
}
}]
}
As described here, if you specify a compositeTemplateId value in the JSON part of the API request, then the "Content-Disposition" value of the corresponding document part within the request must also specify that same value for compositeTemplateId.
If you specify compositeTemplateId within the JSON part of the request, but do NOT specify compositeTemplateId in the Content-Disposition of the corresponding document part within the request, you'll get an error message indicating that the Envelope is incomplete -- because DocuSign cannot locate the document part utilizing the compositeTemplateId value that's specified in the JSON. So, I'd suspect that your issue is being caused by the fact that you're not currently specifying the compositeTemplateId value within the Content-Disposition of the document part in the request.
The following request shows an example of a multi-part "Create Envelope" API request that specifies the same compositeTemplateId value in both:
the inlineTemplate object (within the JSON part of the message)
AND
the Content-Disposition value (within the document part of the message)
Example request
POST https://demo.docusign.net/restapi/v2/accounts/201105/envelopes HTTP/1.1
X-DocuSign-Authentication: {"Username":"johnDoe#gmail.com","Password":"johnsPassword!","IntegratorKey":"ABCD-eae5f282-j4k3-47c3-b293-1c4cf55b-93gh"}
Content-Type: multipart/form-data; boundary=MY_BOUNDARY
Accept: application/json
--MY_BOUNDARY
Content-Type: application/json
Content-Disposition: form-data
{
"emailBlurb":"Test Email Body",
"emailSubject": "Test Email Subject",
"status" : "sent",
"compositeTemplates": [
{
"compositeTemplateId": 1,
"inlineTemplates": [
{
"sequence" : 1,
"customFields": {
"textCustomFields": [
{
"value": "1234567",
"required": "false",
"show": "true",
"name": "ProductId"
}
]
},
"recipients": {
"signers" : [{
"email": "sallysEmail#outlook.com",
"name": "Sally Adamson",
"recipientId": "1",
"defaultRecipient": "true",
"emailNotification": {
"emailSubject": "Recipient specific subject",
"emailBody": "Recipient specific body"
}
}]
}
}],
"document": {
"documentId": 1,
"name": "NDA",
"transformPdfFields": "true"
}
}]
}
--MY_BOUNDARY
Content-Type: application/pdf
Content-Disposition: file; filename="SampleForm.pdf"; compositeTemplateId="1"; documentid="1"
...pdf_byte_stream_here...
--MY_BOUNDARY--
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"
}
]
}
}
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--