title: Docusign API PHP TemplatesApi::updateDocument FORMAT_CONVERSION_ERROR
body: <p>I'm trying to update a template document via PHP API using this: <a href="https://github.com/docusign/docusign-php-client/blob/master/src/Api/TemplatesApi.php#L4946" rel="nofollow noreferrer">https://github.com/docusign/docusign-php-client/blob/master/src/Api/TemplatesApi.php#L4946</a></p>
  
  <p>I get one of two errors depending on if I set the <code>apply_document_fields</code> option.</p>
  
  <p>Without it set, I get <code>UNSPECIFIED ERROR</code> <code>Value cannot be null.\r\nParameter name: fileBytes</code>. However, if I view the request body before sending, <code>document_base_64</code> is set as expected.</p>
  
  <p>With <code>apply_document_fields</code> set <code>'true'</code> (actual boolean value is not supported), I get <code>FORMAT_CONVERSION_ERROR</code> <code>The data could not be converted.</code></p>
  
  <p>Either way, it seems like the document data is not getting sent correctly, but I can't figure out how I'm supposed to be sending it. Here's my code:</p>
  
  <pre><code>public static function updateTemplateWithDocument(string $documentId, string $templateId, $documentBody = null)
  {
      $api = My_Service_Docusign::getInstance();
      $templatesApi = new DocuSign\eSign\Api\TemplatesApi($api-&gt;getAuth());
  
      $document = new \DocuSign\eSign\Model\Document();
      $document-&gt;setDocumentBase64(base64_encode($documentBody));
      // Got an error reusing $documentId, so I'm incrementing it now
      $document-&gt;setDocumentId((string) (((int)$documentId) + 1));
  
      $def = new DocuSign\eSign\Model\EnvelopeDefinition();
      $def-&gt;setDocuments(array($document));
  
      $opts = new \DocuSign\eSign\Api\TemplatesApi\UpdateDocumentOptions();
      // Different behavior with this set vs not
      $opts-&gt;setApplyDocumentFields('true');
  
      $res = $tmpApi-&gt;updateDocument($api-&gt;getAccountId(), $documentId, $templateId, $def, $opts);
  
      return $res;
  }
  </code></pre>
  
  <p>Unfortunately, DocuSign support doesn't support their API :-(</p>