Reputation: 831
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": "[email protected]",
"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--
Upvotes: 0
Views: 1091
Reputation: 13480
Each individual compositeTemplate object in the request must specify both:
AND
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":"[email protected]","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": "[email protected]",
"name": "Abby Abbott",
"recipientId": "1",
"roleName": "Initiator",
"routingOrder":"1"
}
]
}
}]
},
{
"inlineTemplates": [
{
"sequence" : 1,
"recipients": {
"signers" : [{
"email": "[email protected]",
"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":"[email protected]","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": "[email protected]",
"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": "[email protected]",
"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:
Upvotes: 2
Reputation: 9356
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"
}
Upvotes: 1