0

我有一个复合模板,用于发送以下内容:

  1. 1份签署文件
  2. 另一个不需要签名但包含在内的文档
  3. 存储在模板中的文档

我收到此错误:执行 Web 请求时出错。{ "errorCode": "UNSPECIFIED_ERROR", "message": "Base-64 字符数组或字符串的长度无效。" 我已经验证 Base64 是 4 的倍数。我认为问题在于我没有正确的内容类型。我正在使用 Nintex 和 SharePoint 将 Rest API 发送到 DocuSign。

内容类型:multipart/form-data;boundary=MY_BOUNDARY

Accept: application/json
Host: na2.docusign.net


--MY_BOUNDARY
Content-Type: application/json
Content-Disposition: form-data

{
"emailSubject": "Contract Package for {ItemProperty:Title}",
"status" : "sent",
"compositeTemplates": [
{
"inlineTemplates": [
    {
        "sequence" : 2,
        "recipients": {
            "signers" : [
            {
                "email": "{WorkflowVariable:varCreatedByEmail}",
                "name": "{WorkflowVariable:varCreatedByName}",
                "recipientId": "1",
                "roleName": "MI Employee",
                "routingOrder": "1",
                "tabs":
                    {"signerAttachmentTabs": [
                        {"anchorString": "/ea1/",
                            "anchorXOffset": "1",
                            "anchorYOffset": "0",
                            "tabLabel": "Scope of Work Attachment",
                            "optional": "true",
                            "tabOrder": 1},
                        {"anchorString": "/ea2/",
                            "anchorXOffset": "1",
                            "anchorYOffset": "0",
                            "tabLabel": "Pricing Attachment",
                            "optional": "true",
                            "tabOrder": 3}],
                    "textTabs":[
                        {"anchorString": "/ec1/",
                            "anchorXOffset": "1",
                            "anchorYOffset": "0",
                            "tabLabel": "Scope of Work Text",
                            "disableAutoSize": true,
                            "width": 550,
                            "height": 220,
                            "tabOrder": 2},
                        {"anchorString": "/ec2/",
                            "anchorXOffset": "1",
                            "anchorYOffset": "0",
                            "tabLabel": "Pricing Text",
                            "disableAutoSize": true,
                            "width": 550,
                            "height": 220,
                            "tabOrder": 4}]
                    }
            },
            {
                "email": "{ItemProperty:E_x002d_Mail}",
                "name": "{ItemProperty:Primary_x0020_Contact}",
                "recipientId": "2",
                "roleName": "Vendor",
                "routingOrder": "2",
                "tabs": 
                    {"fullNameTabs": [
                        {"anchorString": "/vn/",
                            "anchorXOffset": "1",
                            "anchorYOffset": "0"}]
                ,
                    "signHereTabs":[
                        {"anchorString": "/vs/",
                            "anchorXOffset": "1",
                            "anchorYOffset": "0"}]
                ,
                    "dateSignedTabs":[
                        {"anchorString": "/dvs/",
                            "anchorXOffset": "1",
                            "anchorYOffset": "0"}]
                ,
                    "initialHereTabs":[
                        {"anchorString": "/vi/",
                            "anchorXOffset": "1",
                            "anchorYOffset": "0"}]
                ,
                    "titleTabs":[
                        {"anchorString": "/vt/",
                            "anchorXOffset": "1",
                            "anchorYOffset": "0"}]
                ,
                    "emailAddressTabs":[
                        {"anchorString": "/ve/",
                            "anchorXOffset": "1",
                            "anchorYOffset": "0"}]
                ,
                    "textTabs":[
                        {"anchorString": "/va1/",
                            "anchorXOffset": "1",
                            "anchorYOffset": "0",
                            "tabLabel": "Address Line 1"},
                        {"anchorString": "/va2/",
                            "anchorXOffset": "1",
                            "anchorYOffset": "0",
                            "tabLabel": "Address Line 2",
                            "required": false},
                        {"anchorString": "/va3/",
                            "anchorXOffset": "1",
                            "anchorYOffset": "0",
                            "tabLabel": "Address Line 3",},
                        {"anchorString": "/vc/",
                            "anchorXOffset": "1",
                            "anchorYOffset": "0",
                            "tabLabel": "Vendor Name",
                            "disableAutoSize": true,
                            "width": 225,
                            "height": 32}]
                    }   
            },
            {
                "email": "{WorkflowVariable:varContractApproverEmail}",
                "name": "{WorkflowVariable:varContractApproverName}",
                "recipientId": "3",
                "roleName": "MI Approver",
                "routingOrder": "3",
                "tabs":
                    {"signHereTabs":[
                        {"anchorString": "/as/",
                            "anchorXOffset": "1",
                            "anchorYOffset": "0"}]
                ,
                    "dateSignedTabs":[
                        {"anchorString": "/das/",
                            "anchorXOffset": "1",
                            "anchorYOffset": "0"}]
                ,
                    "fullNameTabs":[
                        {"anchorString": "/an/",
                            "anchorXOffset": "1",
                            "anchorYOffset": "0"}]
                ,
                    "titleTabs":[
                        {"anchorString": "/at/",
                            "anchorXOffset": "1",
                            "anchorYOffset": "0"}]
                ,
                    "emailAddressTabs":[
                        {"anchorString": "/ae/",
                            "anchorXOffset": "1",
                            "anchorYOffset": "0"}]
                    }
            }           ]
                    }
    }               ],
    "document": {
        "documentId": 1,
        "name": "{WorkflowVariable:varContractName}",
        "documentbase64": "{WorkflowVariable:varContractBase64}"
    }
},
{
"inlineTemplates": [
    {
        "sequence" : 3,
        "recipients": {
            "carbonCopies" : [
            {
                "email": "{WorkflowVariable:varCreatedByEmail}",
                "name": "{Common:InitiatorsDisplayName}",
                "recipientId": "1",
                "roleName": "MI Employee",
                "routingOrder": "1"
            },
            {
                "email": "{ItemProperty:E_x002d_Mail}",
                "name": "{ItemProperty:Primary_x0020_Contact}",
                "recipientId": "2",
                "roleName": "Vendor",
                "routingOrder": "2"
            },
            {
                "email": "{WorkflowVariable:varContractApproverEmail}",
                "name": "{WorkflowVariable:varContractApproverName}",
                "recipientId": "3",
                "roleName": "MI Approver",
                "routingOrder": "3"
            }]
        }
    }],
    "document": {
        "documentId": 2,
        "name": "{WorkflowVariable:varExhibitAName}",
        "documentbase64": "{WorkflowVariable:varExhibitABase64}"
    }
},
{
    "serverTemplates": [
    {
        "sequence" : 6,
        "templateId": "D7472F81-46F9-4BEB-9017-DFAD3C0BCE83"
    }],
    "inlineTemplates": [
    {
        "sequence" : 7,
        "recipients": {
            "signers" : [{
                "email": "{WorkflowVariable:varCreatedByEmail}",
                "name": "{Common:InitiatorsDisplayName}",
                "recipientId": "1",
                "roleName": "MI Employee",
                "routingOrder": "1"
            },
            {
                "email": "{ItemProperty:E_x002d_Mail}",
                "name": "{ItemProperty:Primary_x0020_Contact}",
                "recipientId": "2",
                "roleName": "Vendor",
                "routingOrder": "2",
                "tabs": {
                "textTabs": [
                {
                "tabLabel": "VendorName"}]}
            },
            {
                "email": "{WorkflowVariable:varContractApproverEmail}",
                "name": "{WorkflowVariable:varContractApproverName}",
                "recipientId": "3",
                "roleName": "MI Approver",
                "routingOrder": "3"
            }
            ]
        }
    }],
    "document": {
        "documentId": 4,
        "name": "CCare_Pledge.pdf"
    }
}]
}

--MY_BOUNDARY
Content-Type: application/pdf
Content-Disposition: file; filename="{WorkflowVariable:varContractName}";     documentid="1"

<document bytes removed>

--MY_BOUNDARY--
Content-Type: application/pdf
Content-Disposition: file; filename="{WorkflowVariable:varExhibitAName}";     documentid="2"

<document bytes removed>

--MY_BOUNDARY--
Content-Type: application/pdf
Content-Disposition: file; filename="CCare_Pledge.pdf"; documentid="4"

链接到 base64- http://www.mihomes.com/corp/vit/Base64.txt

4

1 回答 1

0

在查看您发布的请求时,我突然想到了一些事情:

首先,您错误地为将documentid=2指定为“ --MY_BOUNDARY-- ” 的部分指定了边界分隔符

--MY_BOUNDARY--
Content-Type: application/pdf
Content-Disposition: file; filename="{WorkflowVariable:varExhibitAName}";     documentid="2"

通过在此边界字符串的末尾包含--,您表示多部分消息的结尾,因此 DocuSign 很可能没有读取此字符串后面的任何请求内容。我建议将其更改为“ --MY_BOUNDARY”

其次,您要为两个文档(documentid=1 和 documentid=2)多次指定文档字节——一次作为每个复合模板中文档对象的一部分(使用documentbase64属性),然后在附加部分中再次指定的多部分请求。我建议从每个复合模板对象的文档对象中删除documentbase64属性——如果您在多部分消息的其他部分中指定文档字节,则不需要它。

接下来,如果Ccare_Pledge.pdf是您正在使用的模板中包含的第一个文档,那么您应该从该复合模板对象中删除文档属性(对象):

"document": {
    "documentId": 4,
    "name": "CCare_Pledge.pdf"
}

并删除请求的最后部分:

--MY_BOUNDARY--
Content-Type: application/pdf
Content-Disposition: file; filename="CCare_Pledge.pdf"; documentid="4"

这不是必需的,因为文档来自模板本身,因此您无需在请求中指定文档信息。

最后,确保您的请求以正确的边界终止符字符串结尾:

--MY_BOUNDARY--

(其他帖子的答案显示了关于边界分隔符的整体请求结构的一个很好的例子。)

实施这些建议的更改后,您的请求结构应如下所示:

--MY_BOUNDARY
Content-Type: application/json
Content-Disposition: form-data

{
    "emailSubject": "Contract Package for {ItemProperty:Title}",
    "status" : "sent",
    "compositeTemplates": [
        {
            "inlineTemplates": [
                {
                    "sequence" : 2,
                    "recipients": {
                        ...
                    }
                }
            ],
            "document": {
                "documentId": 1,
                "name": "{WorkflowVariable:varContractName}"
            }
        },
        {
            "inlineTemplates": [
                {
                    "sequence" : 3,
                    "recipients": {
                        ...
                    }
                }
            ],
            "document": {
                "documentId": 2,
                "name": "{WorkflowVariable:varExhibitAName}"
            }
        },
        {
            "serverTemplates": [
                {
                    "sequence" : 6,
                    "templateId": "D7472F81-46F9-4BEB-9017-DFAD3C0BCE83"
                }
            ],
            "inlineTemplates": [
                {
                    "sequence" : 7,
                    "recipients": {
                        ...
                    }
                }
            ]
        }
    ]
}

--MY_BOUNDARY
Content-Type: application/pdf
Content-Disposition: file; filename="{WorkflowVariable:varContractName}"; documentid="1"

<document bytes removed>

--MY_BOUNDARY
Content-Type: application/pdf
Content-Disposition: file; filename="{WorkflowVariable:varExhibitAName}"; documentid="2"

<document bytes removed>

--MY_BOUNDARY--
于 2016-07-25T14:55:51.810 回答