文档签名 API PHP 模板Api::updateDocument FORMAT_CONVERSION_ERROR.



我正在尝试使用以下方法通过 PHP API 更新模板文档:https://github.com/docusign/docusign-php-client/blob/master/src/Api/TemplatesApi.php#L4946

我收到两个错误之一,具体取决于我是否设置了apply_document_fields选项。

没有设置,我得到UNSPECIFIED ERRORValue cannot be null.rnParameter name: fileBytes.但是,如果我在发送之前查看请求正文,则会按预期设置document_base_64

使用apply_document_fields设置'true'(不支持实际布尔值(,我得到FORMAT_CONVERSION_ERRORThe data could not be converted.

无论哪种方式,似乎文档数据都没有正确发送,但我无法弄清楚我应该如何发送它。这是我的代码:

public static function updateTemplateWithDocument(string $documentId, string $templateId, $documentBody = null)
{
$api = My_Service_Docusign::getInstance();
$templatesApi = new DocuSigneSignApiTemplatesApi($api->getAuth());
$document = new DocuSigneSignModelDocument();
$document->setDocumentBase64(base64_encode($documentBody));
// Got an error reusing $documentId, so I'm incrementing it now
$document->setDocumentId((string) (((int)$documentId) + 1));
$def = new DocuSigneSignModelEnvelopeDefinition();
$def->setDocuments(array($document));
$opts = new DocuSigneSignApiTemplatesApiUpdateDocumentOptions();
// Different behavior with this set vs not
$opts->setApplyDocumentFields('true');
$res = $tmpApi->updateDocument($api->getAccountId(), $documentId, $templateId, $def, $opts);
return $res;
}

不幸的是,DocuSign 支持不支持他们的 API :-(

我想我需要改用TemplatesApi::updateDocuments(复数(,这也允许我重用documentId

最新更新