【问题标题】:Passing Non-Latin UTF-8 Characters in Text Tabs via DocuSign REST API通过 DocuSign REST API 在文本选项卡中传递非拉丁 UTF-8 字符
【发布时间】:2014-10-07 18:23:32
【问题描述】:

我需要能够通过用于嵌入式签名的 REST API 将非拉丁字符传递到文本选项卡,但是 ASCII 中未包含的任何内容都会导致 URL 超时。

在旧的 DocuSign 社区论坛上,有人暗示只支持 ASCII 字符,但没有得到确认。你可以在这里看到它:

http://community.docusign.com/t5/Misc-Dev-Archive-READ-ONLY/File-names-with-CJK-characters/td-p/20249

谁有更多关于通过 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


    【解决方案1】:

    DocuSign 的 REST API 现在确实支持非拉丁 UTF 字符。我已经运行了一些最近的测试,这按预期工作,所以请再次尝试您的请求,如果没有工作,请在您的问题中发布您的请求正文。

    这是我刚刚测试过的示例 JSON 请求正文之一,请注意 textTab 的值:

    {
        "emailSubject": "DocuSign REST API Testing",
        "documents": [
            {
                "documentId": "1",
                "name": "test.pdf"
            }
        ],
        "recipients": {
            "signers": [
                {
                    "email": "docusigndemo@gmail.com",
                    "name": "Ergin D.",
                    "recipientId": "1",
                    "tabs": {
                        "signHereTabs": [
                            {
                                "xPosition": "100",
                                "yPosition": "100",
                                "documentId": "1",
                                "pageNumber": "1"
                            }
                        ],
                        "textTabs": [
                            {
                                "xPosition": "200",
                                "yPosition": "100",
                                "documentId": "1",
                                "pageNumber": "1",
                                "tabLabel": "name",
                                "value": "Цццццццasdfasfd"
                            }
                        ]
                    }
                }
            ]
        },
        "status": "sent"
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-03-22
      • 1970-01-01
      • 1970-01-01
      • 2013-04-21
      • 1970-01-01
      • 2011-01-02
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多