Reputation: 11
I'm working with the Request Signature from Document in the DocuSign API Walkthrough. What I'd like to do is define a template with specific fields then apply that template to the Document that I'm sending via this request. The problem I have is that when I add the template details to the code it gives an error that the envelope is not complete.
This is the page I'm using as reference: http://iodocs.docusign.com/APIWalkthrough/requestSignatureFromDocument
I have a Template defined with a field such as [[canidate_signature]] as an anchor. In the UI, I can upload a document using that anchor and assign the template I've defined which works great. But, I can't get the API to do the same thing.
This is my JSON build code in PHP, which works without the compositeTemplate section but as soon as I add that I get an error.
The Envelope is not Complete. A Complete Envelope Requires Documents, Recipients, Tabs, and a Subject Line.
$data = array (
"emailSubject" => "DocuSign API - Signature Request on Document"
,"compositeTemplates" => array(
array(
"serverTemplates" =>
array(
array(
"sequence" => 1,
"templateId" => "B1E2A5C9-9818-4BF0-AD9F-F4B1A3E2D39D"
)
)
)
)
,"documents" => array(
array(
"documentId" => "1"
,"name" => $documentName
)
,array(
"documentId" => "2"
,"name" => $documentName
)
)
,"recipients" => array(
"signers" => array(
array(
"email" => $email,
"name" => $recipientName,
"recipientId" => "1"
)
,array(
"email" => "***@gmail.com",
"name" => "Scott Gmail",
"recipientId" => "2"
)
)
)
,"status" => "sent"
);
Upvotes: 1
Views: 1381
Reputation: 9356
When requesting a signature through the DocuSign API there are two general ways of doing so: using a template or using a local document. The template has the document(s) saved with it on the server side, the local document method requires that you upload the document bytes as part of the request.
One of the main differences between these two requests is that the Content-Type
for the local document request is multipart/form-data
, whereas the request that sends from a template has a content-type of application/json
(or if you're using XML format then application/xml
) since you are not specifying a document and just need to specify properties through the request body.
What you want is this API walkthrough instead, Signature Request via Template, and you'll need to modify the body that you send out to include your compositeTemplates
:
http://iodocs.docusign.com/APIWalkthrough/requestSignatureFromTemplate
For more help see the following git repo for a webinar that I held last year concerning templates and composite templates. Example 3 in particular is a good one to look at:
https://github.com/Ergin008/DocuSign-REST-API-Webinar-April2013
This is the sample request body that example 3 uses for compositeTemplates:
{
"emailSubject": "DocuSign Templates Webinar - Example 3",
"emailBlurb": "Example #3 - Composite Templates",
"status": "sent",
"compositeTemplates": [
{
"serverTemplates": [
{
"sequence": "1",
"templateId": "55A80182-2E9F-435D-9B16-FD1E1C0F9D74"
}
],
"inlineTemplates": [
{
"sequence": "1",
"recipients": {
"signers": [
{
"email": "[email protected]",
"name": "John Doe",
"recipientId": "1",
"roleName": "RoleOne"
}
]
}
}
]
},
{
"serverTemplates": [
{
"sequence": "2",
"templateId": "44D9E888-3D86-4186-8EE9-7071BC87A0DA"
}
],
"inlineTemplates": [
{
"sequence": "2",
"recipients": {
"signers": [
{
"email": "[email protected]",
"name": "Jane Doe",
"recipientId": "1",
"roleName": "RoleOne"
}
]
}
}
]
}
]
}
Upvotes: 3