【发布时间】:2014-10-07 18:23:32
【问题描述】:
我需要能够通过用于嵌入式签名的 REST API 将非拉丁字符传递到文本选项卡,但是 ASCII 中未包含的任何内容都会导致 URL 超时。
在旧的 DocuSign 社区论坛上,有人暗示只支持 ASCII 字符,但没有得到确认。你可以在这里看到它:
谁有更多关于通过 REST API 将非 ASCII 字符传递到文本选项卡的信息?
-更新-
我再次尝试使用西里尔字母和片假名字符,但仍然无法正常工作。当我查看我的请求正文时,它是完美的。
根据 API 日志,正文从末尾开始缺少字符,但数量因我使用的非拉丁字符而异。
- 当我使用 9 个片假名字符时,API 日志显示正文末尾缺少 15 个字符。
- 当我使用 11 个西里尔字符时,API 日志显示正文末尾缺少 11 个字符。
关于可能导致这种情况的任何想法?
我这边的请求正文字符串
<envelopeDefinition xmlns="http://www.docusign.com/restapi">
<status>sent</status>
<emailSubject>Your NDA is ready for signature.</emailSubject>
<enableWetSign>false</enableWetSign>
<DocuSign_FinishLaterAllow>false</DocuSign_FinishLaterAllow>
<templateId>B66F3541-7DE4-42F7-971F-C66D634FA2EC</templateId>
<templateRoles>
<templateRole>
<email>asdfasdf@asdf.com</email>
<name>Japanese Test</name>
<roleName>Signee</roleName>
<clientUserId>1</clientUserId>
<tabs>
<textTabs>
<text>
<tabLabel>streetAddress</tabLabel>
<name>streetAddress</name>
<value>ワタシ</value>
</text>
<text>
<tabLabel>Zip</tabLabel>
<name>Zip</name>
<value>ワタシ</value>
</text>
<text>
<tabLabel>Nationality</tabLabel>
<name>Nationality</name>
<value>Afghanistan</value>
</text>
<text>
<tabLabel>City</tabLabel>
<name>City</name>
<value>ワタシ</value>
</text>
<text>
<tabLabel>Region</tabLabel>
<name>Region</name>
<value>Aiti [Aichi]</value>
</text>
<text>
<tabLabel>Country</tabLabel>
<name>Country</name>
<value>Japan</value>
</text>
</textTabs>
</tabs>
</templateRole>
</templateRoles>
</envelopeDefinition>
根据 DocuSign API 日志的请求正文
<envelopeDefinition xmlns="http://www.docusign.com/restapi">
<status>sent</status>
<emailSubject>Your NDA is ready for signature.</emailSubject>
<enableWetSign>false</enableWetSign>
<DocuSign_FinishLaterAllow>false</DocuSign_FinishLaterAllow>
<templateId>B66F3541-7DE4-42F7-971F-C66D634FA2EC</templateId>
<templateRoles>
<templateRole>
<email>asdfasdf@asdf.com</email>
<name>Japanese Test</name>
<roleName>Signee</roleName>
<clientUserId>1</clientUserId>
<tabs>
<textTabs>
<text>
<tabLabel>streetAddress</tabLabel>
<name>streetAddress</name>
<value>ワタシ</value>
</text>
<text>
<tabLabel>Zip</tabLabel>
<name>Zip</name>
<value>ワタシ</value>
</text>
<text>
<tabLabel>Nationality</tabLabel>
<name>Nationality</name>
<value>Afghanistan</value>
</text>
<text>
<tabLabel>City</tabLabel>
<name>City</name>
<value>ワタシ</value>
</text>
<text>
<tabLabel>Region</tabLabel>
<name>Region</name>
<value>Aiti [Aichi]</value>
</text>
<text>
<tabLabel>Country</tabLabel>
<name>Country</name>
<value>Japan</value>
</text>
</textTabs>
</tabs>
</templateRole>
</templateRoles>
</e
-更新 2- 事实证明,为字节数组获取正确的大小是一个问题。我使用的是 C# Embedded Signing Walkthrough 中的代码。在演练中,它根据字符串的长度而不是字节数组来分配正文大小。
而不是这个(在Embedded Signing Walkthrough)
public static void addRequestBody(HttpWebRequest request, string requestBody)
{
// create byte array out of request body and add to the request object
byte[] body = System.Text.Encoding.UTF8.GetBytes (requestBody);
Stream dataStream = request.GetRequestStream ();
dataStream.Write (body, 0, requestBody.Length);
dataStream.Close ();
}
应该是这个
public static void addRequestBody(HttpWebRequest request, string requestBody)
{
// create byte array out of request body and add to the request object
byte[] body = System.Text.Encoding.UTF8.GetBytes (requestBody);
Stream dataStream = request.GetRequestStream ();
dataStream.Write (body, 0, body.Length);
dataStream.Close ();
}
现在所有 UTF-8 字符都可以使用。片假名字符导致更多正文字符被从末尾删除的原因是亚洲语言字符集往往是 3 个字节,而西里尔文和希腊语往往是 2 个字节。
【问题讨论】:
标签: asp.net xml utf-8 ascii docusignapi