0

I am attempting to use the compositeTemplate to create an envelope with the recipient information and a document provided by the user. Neither the recipient information or the document are added to the envelope at the time of creation. The envelope is however using the template provided in the server template portion. The bytestring variable is the pdfbytes. I am using the REST API. Below is my xml string. Any help is appreciated.

EDITED 9/12 with the same original results. As an additional note, I have successfully created an envelope that includes the provided pdf bytes but does not use any templates.

<envelopeDefinition xmlns="http://www.docusign.com/restapi">
            ...
            <compositeTemplates>
                <compositeTemplate>
                    <serverTemplates>
                       ...
                    </serverTemplates>
                    <inlineTemplates>
                       ...
                    </inlineTemplates>
                    <document>
                        <name>DOCUSIGN API TEST DOC</name>
                        <documentId>123456</documentId>
                        <documentBase64>pdfbytestring</documentBase64>
                    </document>
                </compositeTemplate>
            </compositeTemplates>
        </envelopeDefinition>
Larry K
  • 47,808
  • 15
  • 87
  • 140
Litmas
  • 76
  • 1
  • 1
  • 8
  • So what's the problem? Are you getting you an error message? If so what does it say? Please elaborate... – Ergin Sep 09 '14 at 22:30
  • The problem is that the provided document is not included in the envelope when it is created. The template provided through the server template tag is showing correctly. There is no error message, it simply creates the envelope with the given template but the document. – Litmas Sep 10 '14 at 13:10

1 Answers1

0

PDFBytes is not a valid property of document in the DocuSign REST API -- there's no mention of that property in the REST API Guide. (It is a valid property in the SOAP API -- but you're not using the SOAP API.) That's likely why DocuSign isn't adding the document to the Envelope -- it doesn't recognize the PDFBytes property, so it's simply ignoring it.

You might try using the documentBase64 property (instead of PDFBytes).

In addition to using the documentBase64 property (instead of PDFBytes), I'd also suggest that you revisit your XML request structure -- if you want the Envelope to contain the document that's specified in the API request (and not the document(s) that are part of the template), then your request should be structured like this:

(only the compositeTemplates portion of the request shown here):

<compositeTemplates>
  <compositeTemplate>
      <serverTemplates>
        <serverTemplate>
            ...
        </serverTemplate>
      </serverTemplates>
      <inlineTemplates>
        <inlineTemplate>
            ...
        </inlineTemplate>
      </inlineTemplates>        
      <document>
        <name>DOCUMENT_NAME</name>
        <documentId>DOCUMENT_ID</documentId>
        <documentBase64>DOCUMENT_BYTES</documentBase64>
      </document>
  </compositeTemplate>
</compositeTemplates>

In other words -- make the <document> node a peer element of the inlineTemplates node and serverTemplates node, and remove the encapsulating <documents> element altogether (as I've shown in the example above).

Kim Brandl
  • 13,125
  • 2
  • 16
  • 21
  • In that case do you happen to know what the correct property for use within the REST API is? Additionally, if I include the PDFBytes property in the inline template without providing a the name property for the document name, I do receive an error stating "A document was defined without setting the 'name' field". – Litmas Sep 10 '14 at 15:47
  • Updated my answer with a possible workaround -- try using the documentBase64 property instead. – Kim Brandl Sep 10 '14 at 17:57
  • We've attempted to use that property as well and have been unsuccessful in having the correct document appear. – Litmas Sep 10 '14 at 18:03
  • Kim, I've tried making the suggested changes to my xml structure and am coming up with the same results. Please see my edit to the original post for my current xml structure. – Litmas Sep 12 '14 at 15:54