0

See Updated XML. It has changed the output but still not quite right. Now it uploads doc1 and applies template correctly and inserts templates 2 & 3 in the correct location, however doc2 & doc3 are not there. Just the document that was used to create the template.

<compositeTemplates>
   <compositeTemplate>
     <compositeTemplateId>1</compositeTemplateId>
     <serverTemplates>
      <serverTemplate>
        <sequence>1</sequence>
        <templateId>6A68F081-643D-4DAC-8660-3CC0D59166D5</templateId>
       </serverTemplate>
     </serverTemplates>
     <document>
     <documentId>1</documentId>
         <name>doc1</name>
      </document>
  </compositeTemplate>
  <compositeTemplate>
    <compositeTemplateId>2</compositeTemplateId>
    <serverTemplates>
      <serverTemplate>
        <sequence>1</sequence>
        <templateId>F2807DA5-89E0-445A-BE32-98951C7AD9F0</templateId>
        <compositeTemplateId>2</compositeTemplateId>
       </serverTemplate>
     </serverTemplates>
     <document>
  <documentId>2</documentId>
         <name>doc2</name>
     </document>
  </compositeTemplate>
  <compositeTemplate>
    <compositeTemplateId>3</compositeTemplateId>
    <serverTemplates>
      <serverTemplate>
        <sequence>1</sequence>
        <templateId>B9377A6C-BC24-4175-B749-81629E977C26</templateId>
        <compositeTemplateId>3</compositeTemplateId>
      </serverTemplate>
     </serverTemplates>
      <document>
   <documentId>3</documentId>
       <name>doc3</name>
    </document>
  </compositeTemplate>
</compositeTemplates>

also changed Content-Dispositon

"Content-Disposition: file; filename=\"" + fileName + "\";documentId=1; compositeTemplateId=1\r\n\r\n";
"Content-Disposition: file; filename=\"" + fileName + "\";documentId=2; compositeTemplateId=2\r\n\r\n";
"Content-Disposition: file; filename=\"" + fileName + "\";documentId=3; compositeTemplateId=3\r\n\r\n";
Larry K
  • 47,808
  • 15
  • 87
  • 140

1 Answers1

2

This is REST using XML for payload rather than JSON. In the DocuSign REST API, using compositeTemplates with multi-part form contribution of documents gets a little tricky when applying server templates to those documents. The server template's tabs are assigned to documentId=1. Therefore, you must do the same. To properly map the document contributed by each composite to the correct document contributed per multi-part form, you must use compositeTemplateId.

For each element, add . Make the first one "1", second "2", third "3". Then, for each form where you attach the documents, add the "compositeTemplateId=n" (where n= 1, 2, or 3) to that form's Content-Disposition.

e.g.:

--BOUNDARY
Content-Disposition: file; documentid=1; name="Option2"; filename="Option2.pdf"; compositeTemplateId=2
Content-Type: application/pdf
WTP
  • 530
  • 2
  • 4
  • You still need to fix your documentId values. They will all need to be "1" to match up to the tabs provided by the server templates. Each is scoped to the composite, so there isn't any "collision" between them. The compositeTemplateId is what provides the mapping of the actual document to the related composite. – WTP Mar 19 '15 at 20:20