JSON Docusign 内联多个文档

JSON Docusign Inline mulitpule Documents

我的 Json 正在处理单个文档并转换 PDF 字段,但是当我尝试添加第二个文档时。我收到 JSON 解析错误。

这个有效

"document": {
"documentId": "1",
"name": "Test Contract With Fields.pdf",
"transformPdfFields": "true",
"documentBase64": "'.$documentHashpdf.'"
    }

这也有效,但不会转换 PDFFields。

 "inlineTemplates": [
        {
          "documents": [
            {
              "documentBase64": "<Base64BytesHere>",
              "documentId": "1",
              "name": "test",
              "transformPdfFields": "true"
            },
            {
              "documentBase64": "<Base64BytesHere>",
              "documentId": "2",
              "name": "test 2",
              "order": "2"
            }
          ],

添加 Square [] 和第二个文档中断。尝试制作 Documents

    "document": [{
        "documentId": "1",
        "name": "Test Contract With Fields.pdf",
        "transformPdfFields": "true",
        "documentBase64": "'.$documentHashpdf.'"
    },
    {

        "documentId": "2",
        "name": "Test Contract With Fields 2.pdf",
        "transformPdfFields": "true",
        "documentBase64": "'.$documentHashpdf.'"

    }]

**更新:完成JSON 希望添加第二个 **文档****

{
    "emailBlurb": "Test Blurb",
    "emailSubject": "Test subject",
    "status": "sent",
    "compositeTemplates": [
        {
            "compositeTemplateId": "1",
            "inlineTemplates": [
                {
                    "sequence": "1","documents": [
              {
                "documentBase64": "'.$documentHashpdf.'",
"documentId": "2",
              "name": "Not working", "order": "2"
            }
          ],

                    "recipients": {
                        "signers": [
                            {
                                "email": "*******",
                                "name": "********e",
                                "recipientId": "1",
                                "smsAuthentication": {
                                "senderProvidedNumbers": ["******"]
                                },
                                "idCheckConfigurationName": "SMS Auth $",
                                "requireIdLookup": "true",
                                "clientUserId": "1001",
                                "defaultRecipient": "true",
                                "tabs": {
                                    "signHereTabs": [
                                        {
                                            "pageNumber": "1",
                                            "documentId": "1",
                                            "tabLabel": "text 1",
                                            "recipientId": "1"
                                        }
                                    ],
                                    "fullNameTabs": [
                                        {
                                            "pageNumber": "1",
                                            "documentId": "1",
                                            "xPosition": "20",
                                            "yPosition": "20",
                                            "height": "10",
                                            "width": "20",
                                            "tabLabel": "Text 2",
                                            "recipientId": "1"
                                        }
                                    ],
                                    "dateSignedTabs": [
                                        {
                                            "pageNumber": "1",
                                            "documentId": "1",
                                            "xPosition": "20",
                                            "yPosition": "30",
                                            "height": "10",
                                            "width": "20",
                                            "tabLabel": "text 3",
                                            "recipientId": "1"
                                        }
                                    ]
                                }
                            }
                        ]
                    }
                }
            ],
            "document": {
                "documentId": "1",
                "name": "Working",
                "transformPdfFields": "true",
                "documentBase64": "'.$documentHashpdf.'"
            }       }
    ]

这里是固定的JSON:

    {
        "emailBlurb": "Test Blurb",
        "emailSubject": "Test subject",
        "status": "sent",
        "compositeTemplates": [
            {
                "compositeTemplateId": "1",
                "inlineTemplates": [
                    {
                        "sequence": "1","documents": [
                  {
                    "documentBase64": "'.$documentHashpdf.'",
    "documentId": "2",
                  "name": "Not working", "order": "2"
                }
              ],

                        "recipients": {
                            "signers": [
                                {
                                    "email": "*******",
                                    "name": "********e",
                                    "recipientId": "1",
                                    "smsAuthentication": {
                                    "senderProvidedNumbers": ["******"]
                                    },
                                    "idCheckConfigurationName": "SMS Auth $",
                                    "requireIdLookup": "true",
                                    "clientUserId": "1001",
                                    "defaultRecipient": "true",
                                    "tabs": {
                                        "signHereTabs": [
                                            {
                                                "pageNumber": "1",
                                                "documentId": "1",
                                                "tabLabel": "text 1",
                                                "recipientId": "1"
                                            }
                                        ],
                                        "fullNameTabs": [
                                            {
                                                "pageNumber": "1",
                                                "documentId": "1",
                                                "xPosition": "20",
                                                "yPosition": "20",
                                                "height": "10",
                                                "width": "20",
                                                "tabLabel": "Text 2",
                                                "recipientId": "1"
                                            }
                                        ],
                                        "dateSignedTabs": [
                                            {
                                                "pageNumber": "1",
                                                "documentId": "1",
                                                "xPosition": "20",
                                                "yPosition": "30",
                                                "height": "10",
                                                "width": "20",
                                                "tabLabel": "text 3",
                                                "recipientId": "1"
                                            }
                                        ]
                                    }
                                }
                            ]
                        }
                    },
                    {
                    "documentId": "1",
                    "name": "Working",
                    "transformPdfFields": "true",
                    "documentBase64": "'.$documentHashpdf.'"
                    }       
               ]}
        ]
    }

有 3 个 "models" 用于构造信封。我建议以预期的方式使用复合模板,您可以通过将每个文档封装在单独的 compositeTemplate 元素中来管理对信封的每个文档贡献。我像这样修改了你的 JSON:

{
  "emailBlurb": "Test Blurb",
  "emailSubject": "Test subject",
  "status": "sent",
  "compositeTemplates": [{
      "compositeTemplateId": "1",
      "document": {
        "documentId": "1",
        "name": "Working",
        "transformPdfFields": "true",
        "documentBase64": "'.$documentHashpdf.'"
      },
      "inlineTemplates": [{
        "sequence": "1",
        "recipients": {
          "signers": [{
            "email": "*******",
            "name": "********e",
            "recipientId": "1",
            "smsAuthentication": {
              "senderProvidedNumbers": ["******"]
            },
            "idCheckConfigurationName": "SMS Auth $",
            "requireIdLookup": "true",
            "clientUserId": "1001",
            "defaultRecipient": "true"
          }]
        }
      }]
    },
    {
      "compositeTemplateId": "2",
      "document": {
        "documentBase64": "'.$documentHashpdf.'",
        "documentId": "2",
        "name": "Not working",
        "transformPdfFields": "true"
      },
      "inlineTemplates": [{
        "sequence": "1",
        "recipients": {
          "signers": [{
            "email": "*******",
            "name": "********e",
            "recipientId": "1",
            "smsAuthentication": {
              "senderProvidedNumbers": ["******"]
            },
            "idCheckConfigurationName": "SMS Auth $",
            "requireIdLookup": "true",
            "clientUserId": "1001",
            "defaultRecipient": "true"
          }]
        }
      }]
    }
  ]
}

以这种方式,您希望添加的任何数量的附加文档都只是添加到数组中的另一个 compositeTemplate 元素。这适用于其他文档,无论您是希望转换 PDF 字段、源自 DocuSign 模板的文档,还是要应用模板叠加的任何其他文档。

请注意,仅需要使用 compositeTemplateId 来关联多部分表单附件,这是一种更简洁的处理文档的方式,而不是在 中对它们进行 base64 编码documentBase64 个元素。