Docusign Cannot Post Templates using Docusign Api
<p>i was trying to post templates on docusign api, but the only response is bad request, here's how i i post the data and files (php and guzzle 5)</p>

<pre><code>$data = [
        'emailsubject' =&gt; 'Agreement for ' . $config['deal_name'],
        'documents' =&gt; [
          [
            'name' =&gt; $config['deal_name'],
            'documentId' =&gt; $config['deal_id']
          ]
        ],
        'recipients' =&gt; [
            'signers' =&gt;
            [
              [
                'roleName' =&gt; Config::get('templateRoleName')
              ]
            ]
        ],
        'envelopeTemplateDefinition' =&gt; [
            'name' =&gt; $config['deal_name'],
        ],
        new \GuzzleHttp\Post\PostFile($config['deal_name'], Flysystem::readStream($config['doc_path'])),
    ];

    $res = $this-&gt;client-&gt;createRequest('POST',"$this-&gt;baseUrl/templates", [
        'headers' =&gt; [
            'Content-Type' =&gt; 'multipart/form-data',
            'X-DocuSign-Authentication' =&gt; json_encode([
                'Username' =&gt; Config::get('docusign.email'),
                'Password' =&gt; Config::get('docusign.password'),
                'IntegratorKey' =&gt; Config::get('docusign.integratorKey')
            ]),
        ],
        'body' =&gt; [
          'emailsubject' =&gt; 'Agreement for ' . $config['deal_name'],
          'documents' =&gt; [
            [
              'name' =&gt; $config['deal_name'],
              'documentId' =&gt; $config['deal_id']
            ]
          ],
          'recipients' =&gt; [
              'signers' =&gt;
              [
                [
                  'roleName' =&gt; Config::get('templateRoleName')
                ]
              ]
          ],
          'envelopeTemplateDefinition' =&gt; [
              'name' =&gt; $config['deal_name'],
              'shared' =&gt; false
          ],
          new \GuzzleHttp\Post\PostFile($config['deal_name'], Flysystem::readStream($config['doc_path'])),
        ]
    ]);


    $response = $this-&gt;client-&gt;send($res);
</code></pre>

<p>I think that request is already same as in <a href="https://www.docusign.com/p/RESTAPIGuide/RESTAPIGuide.htm#REST" rel="nofollow">https://www.docusign.com/p/RESTAPIGuide/RESTAPIGuide.htm#REST</a> API References/Post Template.htm%3FTocPath%3DREST%2520API%2520References%7C_____130</p>

<p>Im already implement login, sent signed request from envelope id, but stuck on post templates ( upload data &amp; pdf ), am i missing something?
Here's the error response</p>

<pre><code>Client error response [url] https://demo.docusign.net/restapi/v2/accounts/asdfaccountId/templates [status code] 400 [reason phrase] Bad Request
</code></pre>

<p>Here's the data posted to docusign api, (file section truncated)</p>

<pre><code>POST /restapi/v2/accounts/blablaAccountId/templates HTTP/1.1 Host: demo.docusign.net Content-Type: application/json X-DocuSign-Authentication: {"Username":"blabla@blabla.com","Password":"blabla","IntegratorKey":"blabla"} User-Agent: Guzzle/5.3.0 curl/7.35.0 PHP/5.6.17-3+deb.sury.org~trusty+1 --56af2bf9b3fb2 Content-Disposition: form-data; name="emailsubject" Agreement for asdf --56af2bf9b3fb2 Content-Disposition: form-data; name="documents[0][name]" asdf --56af2bf9b3fb2 Content-Disposition: form-data; name="documents[0][documentId]" asdf --56af2bf9b3fb2 Content-Disposition: form-data; name="envelopeTemplateDefinition[name]" asdf --56af2bf9b3fb2 Content-Disposition: form-data; name="envelopeTemplateDefinition[shared]" --56af2bf9b3fb2 Content-Disposition: form-data; name="asdf"; filename="f2EQySRYpYyGngxuw0bM" 
</code></pre>