---更新了清晰&解決方案---問題添加文檔使用Unicode文件名
,因爲它涉及到對文檔添加到我們注意到我們有上傳包含文檔的問題,現有的信封的能力Unicode文件名中的字符。我們的調用是對/ restapi/v2/accounts/[account id]/envelopes/[envelope id]/documents端點的多部分PUT請求,它將文檔數據作爲二進制內容在消息的其中一部分內發送,而不是base64對文檔進行編碼並將其嵌入爲json有效負載的一部分。
我們很快發現,寫入請求流的代碼部分使用的是Encoding.Ascii,應更改爲使用Encoding.UTF8。
using (var writer = new StreamWriter(stream, Encoding.ASCII, 1024, true))
{
// write boundary, content type, content disposition & json content
}
但是,這種變化產生了一些錯誤信息,這取決於我們試過了,例如:
{
"errorCode": "ENVELOPE_IS_INCOMPLETE",
"message": "The Envelope is not Complete. A Complete Envelope Requires Documents, Recipients, Tabs, and a Subject Line. Envelope definition missing."
}
{
"envelopeId": "XXXXXXX-1869-4555-8831-eb3ed90850c2",
"envelopeDocuments": [
{
"documentId": "1",
"order": "1",
"errorDetails": {
"errorCode": "NO_DOCUMENT_RECEIVED",
"message": "Bytes for document corresponding to documentId 1 not found in request."
}
}
]
}
使用諸如Fiddler &郵差工具,我們現在可以看到出站REST調用,除了現在允許使用Unicode字符外,其他所有意圖和用途都與以前的調用幾乎相同。
PUT https://demo.docusign.net/restapi/v2/accounts/xxxxx/envelopes/xxxxxx-f772-48af-82ac-f0c2e95eaac1/documents HTTP/1.1
Content-Type: multipart/form-data; boundary=soucecode
Accept: application/json
X-DocuSign-Authentication: [Creds Here]
Host: demo.docusign.net
Content-Length: 11691
Expect: 100-continue
--soucecode
Content-Type: application/json
Content-Disposition: form-data
{
"documents": [
{
"order": 1,
"name": "Specíal Character.docx",
"documentId": "1"
}
]
}
--soucecode
Content-Type: application/vnd.openxmlformats-officedocument.wordprocessingml.document
Content-Disposition: file; filename="Specíal Character.docx"; documentid=1
[binary content removed for brevity]
--soucecode--
我能夠使用多部分MIME成功發送UTF-8文件名。看到我下面添加的答案。 –
很高興你解決了這個問題!請將您的解決方案作爲**答案放回**,這樣其他人可以將其解決。你將能夠檢查你的答案是正確的(但不會得到任何分數)。謝謝! –