首页 文章

Docusign-发送信封 REST API(POST multipart/form-data)

提问于
浏览
1

我正在尝试使用 REST API 在 DocuSign 中发送信封。要将文档添加到信封,我使用的是 multipart/form-data POST 方法。我尝试使用 POSTMAN 发送此请求,但收到以下响应:

{
    "errorCode": "INVALID_CONTENT_TYPE",
    "message": "Content Type specified is not supported. Content-Type for part[0] must be application/json or application/xml"
}

这是我的 POSTMAN 请求:

POST /restapi/v2/accounts/****/envelopes HTTP/1.1
Host: demo.docusign.net
Content-Type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW
Authorization: Bearer *********
Cache-Control: no-cache
Postman-Token: c0b940e1-4b6c-4848-abd1-ed5c9c712cb5

------WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name=""

{
  "status": "sent",
  "emailSubject": "Example of one recipient, type signer",
  "documents": [{
    "documentId": "1",
    "name": "contract.pdf",
  }],
  "recipients": {
    "signers": [{
      "name": "Lisa Simpson",
      "email": "lisa@email.com",
      "recipientId": "1",
      "routingOrder": "1",
      "tabs": {
        "signHereTabs": [{
          "xPosition": "150",
          "yPosition": "200",
          "documentId": "1",
          "pageNumber": "1"
        }],
      }
    }]
  }
}
------WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="file"; filename="Test.pdf"
Content-Type: application/pdf

------WebKitFormBoundary7MA4YWxkTrZu0gW--

我的问题是:

  • POSTMAN 中是否可以为 part [5]指定 Content-Type?

  • part [6]和 part [7]的键名应该是什么?

  • 如何部分传递 documentid [8]?

我指的是:https://docs.docusign.com/esign/restapi/Envelopes/Envelopes/create/#个例子 REST API 文档

1 回答

  • 1

    请参阅下面的multi-part 表格multipart/form-data正确的 self-contained 工作 DocuSign 信封-

    DocuSign 支持案例 04093516已关闭,并且针对通过 REST API 发送信封的文档中的form-data错误提起了 Jira 罚单。

    丰厚的回报和间隔至关重要。另外,建议您将电子邮件地址更新为测试 Gmail 帐户,注意可以使用相同的帐户。如果使用 Postman,请确保使用的是“ RAW”而不是 form-data,x-www-form-urlencoded 或二进制文件。见下图:

    在此处输入图片说明

    也在此链接-https://blog.grigsbyconsultingllc.com/wp-content/uploads/Screenshot-2018-04-18-07.26.26.png

    您仍然需要标头,尤其是 content-type 和身份验证类型:-H'content-type:multipart/form-data; boundary=AAA'\ -H'x-docusign-authentication;请参阅堆栈溢出链接标头 X-DocuSign-Authentication 应该如何用于 REST 和 SOAP?

    --AAA
    Content-Type: application/json
    Content-Disposition: form-data
    
    {
    "emailBlurb": "Test for CEFTAF Lab 2 Custom Fields Recipient Fields Document Fields",
    "emailSubject": "Test for Dev 201 Lab 2",
    "status": "created",
                   "notification":{
                  "useAccountDefaults":"false",
                  "reminders":{
                     "reminderEnabled":"true",
                     "reminderDelay":"2",
                     "reminderFrequency":"2"
                  },
                  "expirations":{
                     "expireEnabled":"true",
                     "expireAfter":"15",
                     "expireWarn":"1"
                  }
                  }, 
    "compositeTemplates": [{
    "inlineTemplates": [{
    "sequence": "1",
    "customFields": {
        "textCustomFields": [
          {
            "fieldId": "123",
            "name": "MYCustomID",
            "show": "false",
            "required": "false",
            "value": "myId012345"
          }
        ],
        "listCustomFields": [
          {
            "listItems": [
              "elementValue1","elementValue2","elementValue3"
            ],
            "fieldId": "1234",
            "name": "myArrayListofItems",
            "show": "false",
            "required": "false",
            "value": "3"
          }
        ]
      },
    
    "documents": [{
    "documentId": "1",
    "name": "test1.txt",
          "documentFields": [
            {
              "name": "Test1",
              "value": "value for test1"
            }
          ],
    },
                {
    "documentId": "2",
    "name": "test2.txt"
    },
                {
    "documentId": "3",
    "name": "test3.txt"
    }
    
                ],
    "recipients": {
                "carbonCopies": [
                                {
                                    "email": "dsproservedemosoapui+Testcc@gmail.com",
                                    "name": "David Grigsby (see all document)",
                                    "recipientId": "3",
                                    "routingOrder": "3"
                                },
                                {
                                    "email": "dsproservedemosoapui+Testcc1@gmail.com",
                                    "name": "David Grigsby (see all)",
                                    "recipientId": "4",
                                    "routingOrder": "4"
                                }
                                ],
    "signers": [{
    "recipientId": "1",
    "customFields": [
      "Recip 1 ID 1234"
    ],
    "name": "David Grigsby (Sees all)",
    "email": "dsproservedemosoapui+Test1@gmail.com", 
                        "routingOrder": "1",
                        "tabs": {
                        "signHereTabs": [{
                          "anchorString": "Sign1",
                          "tabLabel": "Sign Here 1"
                          }]
                        }
    },
                    {
    "recipientId": "2",
    "name": "David Grigsby (sees all )",
    "email": "david.grigsby@yahoo.com", 
                        "routingOrder": "2",
                        "tabs": {
                        "signHereTabs": [{
                          "anchorString": "Sign2",
                          "tabLabel": "Sign Here 2"
                          }]
                        }
    }
                    ]
    }
    }]
    }]
    }
    
    --AAA
    Content-Type: application/txt
    Content-Disposition: file; filename="test1.txt"; documentid=1
    
    Test Document 1 
    
    Sign1 Here _______________________________    Custom1 Approve:
    
    Sign2 Here _______________________________    Custom2 Approve:
    
    --AAA
    Content-Type: application/txt
    Content-Disposition: file; filename="test2.txt"; documentid=2
    
    Test Document 2
    
    Sign1 Here _______________________________
    
    --AAA
    Content-Type: application/txt
    Content-Disposition: file; filename="test3.txt"; documentid=3
    
    Test Document 3
    
    No Tabs for anyone means visbile to all by default unless excluded
    
    --AAA--
    

    与 PDF 的区别如下,建议使用 Base64

    --AAA
    Content-Type: application/pdf
    Content-Disposition: file; filename="f4506t.pdf"; documentid=1
    Content-Transfer-Encoding: base64
    
    JVBERi0xLjcNJeLjz9MNCjMwMSAwIG9iag08PC9MaW5lYXJpemVkIDEvTCA3NDAzMi9PIDMwMy9F
    IDMzNjI2L04gMi9UIDczNjM4L0ggWyA2MzAgMjk2XT4+DWVuZG9iag0gICAgICAgICAgICAgICAg
    

    .... pdf 主体已移除......

    o4IlmH0CxPYUYWBiYGBUB5PVDADOVQiaCmVuZHN0cmVhbQplbmRvYmoKc3RhcnR4cmVmCjg1MDUz
    CiUlRU9GCg==
    --AAA--
    

    来自 DocuSign 案例的注释图像:
    在此处输入图片说明

相关问题