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 hav
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--