通过DocuSign Rest API创建DocuSign Envelope时出错(包含多个文档和多个收件人)

时间:2013-12-11 03:47:30

标签: json rest pdf docusignapi

我正在尝试使用DocuSign REST API在DocuSign中创建包含多个文档的Envelope,我正在使用multipart / form-data请求,我使用JSON来定义信封的属性,我检查我的JSON和I认为没关系。下面我定义了一个multipart / mixed部分,我在其中设置了文档的标题和PDF字节。我收到一个错误的请求错误代码,上面写着“NO_DOCUMENT_RECEIVED”并且有一条消息“文档元素不包含编码文档,或者编码有问题。”。我在下面的fiddler发布请求结果:

//请求

POST https://demo.docusign.net/restapi/v2/accounts/295724/envelopes HTTP/1.1
X-DocuSign-Authentication: {"Username":"email","Password":"password","IntegratorKey":"key"}
Content-Type: multipart/form-data; boundary=9a56da749dc04804819460f6499ab80b
Accept: application/json
Host: demo.docusign.net
Content-Length: 31476
Expect: 100-continue

--9a56da749dc04804819460f6499ab80b
Content-Type: application/json
Content-Disposition: form-data

{"emailBlurb":"EMAIL BODY HERE OK OK","emailSubject":"EMAIL SUBJECT HERE IS MANDATORY","status":"sent","documents":[{"documentId":1,"name":"ABC.pdf"},{"documentId":2,"name":"AB.pdf"}],"recipients":{"signers":[{"email":"dn@brenock.com","name":"Dubhe","recipientId":"1","routingOrder":"1"},{"email":"dubhe.dnacimiento@gmail.com","name":"DubheF","recipientId":"2","routingOrder":"1"}]}}
--9a56da749dc04804819460f6499ab80b
Content-Disposition: form-data
Content-Type: multipart/mixed; boundary=e8bc9555e9634110bba63547b2552460

--e8bc9555e9634110bba63547b2552460
Content-Type: application/pdf
Content-Disposition: file; filename=ABC.pdf; documentId=1

<PDF Bytes Document 1>
--e8bc9555e9634110bba63547b2552460
Content-Type: application/pdf
Content-Disposition: file; filename=AB.pdf; documentId=2

<PDF BytesDocument Two>
--e8bc9555e9634110bba63547b2552460--
--9a56da749dc04804819460f6499ab80b--

1 个答案:

答案 0 :(得分:0)

您不应该需要这些行来定义第二个边界(或对该第二个边界的任何后续引用):

Content-Disposition: form-data
Content-Type: multipart/mixed; boundary=e8bc9555e9634110bba63547b2552460

尝试删除(以及对边界 e8bc9555e9634110bba63547b2552460 的所有后续引用),以便您的请求如下所示:

POST https://demo.docusign.net/restapi/v2/accounts/295724/envelopes HTTP/1.1
X-DocuSign-Authentication: {"Username":"email","Password":"password","IntegratorKey":"key"}
Content-Type: multipart/form-data; boundary=9a56da749dc04804819460f6499ab80b
Accept: application/json
Host: demo.docusign.net
Content-Length: 31476
Expect: 100-continue

--9a56da749dc04804819460f6499ab80b
Content-Type: application/json
Content-Disposition: form-data

JSON_REQUEST_BODY_HERE
--9a56da749dc04804819460f6499ab80b
Content-Type:application/pdf
Content-Disposition: file; filename="ABC.pdf"; documentid=1 

DOCUMENT_1_BYTES_HERE
--9a56da749dc04804819460f6499ab80b
Content-Type:application/pdf
Content-Disposition: file; filename="AB.pdf"; documentid=2 

DOCUMENT_2_BYTES_HERE
--9a56da749dc04804819460f6499ab80b--