Alex-Potter
Alex-Potter

Reputation: 3

Passing Non-Latin UTF-8 Characters in Text Tabs via DocuSign REST API

I need to be able to pass non-Latin characters into text tabs via the REST API for Embedded Signing, but anything that isn't included in ASCII causes the URL to time out.

On the old DocuSign community forum, it was hinted that only ASCII characters are supported, but there was no confirmation. You can see it here:

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

Does anyone have any more information on passing non-ASCII characters into text tabs via the REST API?

-Update-

I tried again using Cyrillic and Katakana characters and it still isn't working. When I view my request body, it is perfect.

According to the API logs, the body is missing characters from the end, but the amount differs based on what non-Latin characters I use.

Any ideas as to what might be causing this?

The request body string on my end

<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>[email protected]</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>

The request body according to the DocuSign API Log

<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>[email protected]</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

-Update 2- It turns out it was an issue with getting the right size for the byte array. I was using code from the C# Embedded Signing Walkthrough. In the walkthrough it assigns the body size from the length of the string rather than the byte array.

Instead of this (In the 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 ();
    }

It should be this

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 ();
    }

Now all UTF-8 characters work. The reason the Katakana characters led to more body characters being removed from the end is that the Asian language character sets tend to be 3 bytes whereas the Cyrillic and Greek tends to be 2.

Upvotes: 0

Views: 436

Answers (1)

Ergin
Ergin

Reputation: 9356

Non-Latin UTF characters are indeed now supported through DocuSign's REST API. I've run some recent tests and this is working as expected so please try your request again and if not working post your request body in your question.

Here's one of the sample JSON request bodies that I just tested with, notice the value of the textTab:

{
    "emailSubject": "DocuSign REST API Testing",
    "documents": [
        {
            "documentId": "1",
            "name": "test.pdf"
        }
    ],
    "recipients": {
        "signers": [
            {
                "email": "[email protected]",
                "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"
}

Upvotes: 1

Related Questions