DocuSign API替换模板文档但保留字段

时间:2017-05-05 17:37:27

标签: php docusignapi

我想使用服务器模板中的现有字段而不是其他文档。

首先,我尝试将文档附加到与内联/服务器相同的级别。 如果我已经定义了签名者,它会给我一个400错误,如果我把它关掉(偶然的话)它会完全消除字段并显示附加文档。

其次,我尝试将文档附加到内联模板,但这会导致附加文档不显示,它只是正常运行。

更新

添加其他调试和研究后,我现在知道将其附加到内联模板是不正确的。添加调试以读取400响应后,我收到此错误:

  

" tab元素中指定的DocumentId不引用此信封中的文档。 Tab指的是不存在的DocumentId 32475214。"

DocumentId被设置为1,这显然是错误的。

这导致我在SO上question。其中一条评论提到应该使用从400回来的ID。 在我对此ID进行硬编码后,我发现更换操作是成功的!

但是我现在需要找到一种方法查找并以编程方式插入该值。

详细

我正在使用DocuSign php sdk来帮助我构建数据结构并访问api。

1 个答案:

答案 0 :(得分:2)

使用listTemplateDocuments API检索模板的documentId。

上述步骤中检索到的 documentId 应该在CreateEnvelope请求的CompositeTemplate中使用

{
  "emailSubject": "Tabs should remain from the Server Template",
  "status": "sent",
  "compositeTemplates": [
    {
      "document": {
            "documentId": "<document Id>", //Use the documentId retrieved using the listTemplateDocuments api
            "name": "Replaced Document",
            "fileExtension": "txt",
            "documentBase64": "RG9jIFRXTyBUV08gVFdP"
        },
        "serverTemplates": [
            {
                "sequence": "1",
                "templateId": "<Server Template Id Here>"
            }
        ]
    }
  ]
}