Docusign错误:“;“信封_IS_不完整”;当I';我正试图创建一个信封C#和Json

本文关键字:创建 Json 一个 IS 信封 错误 Docusign | 更新日期: 2023-09-27 18:26:59

我正试图用C#通过rest web api v2创建一个信封。我可以登录,但当我试图用模板创建信封时,我会遇到这个错误。

{
  "errorCode": "ENVELOPE_IS_INCOMPLETE",
  "message": "The Envelope is not Complete. A Complete Envelope Requires Documents, Recipients, Tabs, and a Subject Line. Content-Type does not contain boundary parameter."
}

这是我的儿子:

{
  "status": "sent",
  "emailSubject": "DocuSign API - Embedded Signing example",
  "templateId": "96e27a15-2763-4e05-86c8-29e7b4e30f64",
  "templateRoles": {
    "templateRole": [
      {
        "email": "micorreo@email.com",
        "name": "Gustavo",
        "roleName": "micorreo@email.com",
        "clientUserId": "1",
        "tabs": {
          "textTabs": [
            {
              "text": {
                "tabLabel": "tabLabel1",
                "value": "Value1"
              }
            }
          ]
        }
      }
    ]
  },
  "documents": [
    {
      "documentId": "1",
      "name": "My First DocuSign.docx"
    }
  ]
}

我的C#函数:

 public bool Create()
    {
        bool result = false;
        try
        {
            //============================================================================
            //  STEP 2 - Create an Envelope from Template and Send
            //============================================================================
            string templateId = "96e27a15-2763-4e05-86c8-29e7b4e30f64";
            // append "/envelopes" to baseURL and use for signature request api call
            string url = AccountManager.Instance.CurrentAccount.baseUrl + "/envelopes";
            string recipientEmail = "micorreo@email.com";
            string recipientName = "Gustavo";
            string templateRole = "micorreo@email.com";
            //Content-Disposition: form-data
            string requestBody =
                            "{" +
                                "'"status'": '"sent'"," +
                                "'"emailSubject'": '"DocuSign API - Embedded Signing example'"," +
                                "'"templateId'": '"96e27a15-2763-4e05-86c8-29e7b4e30f64'"," +
                                "'"templateRoles'":{" +
                                                    "'"templateRole'": [{" +
                                                                        "'"email'": '"micorreo@email.com'"," +
                                                                        "'"name'": '"Gustavo'"," +
                                                                        "'"roleName'": '"micorreo@email.com'"," +
                                                                        "'"clientUserId'": '"1'"," +
                                                                          "'"tabs'": {" +
                                                                                        "'"textTabs'": [{" +
                                                                                                        "'"text'": {" +
                                                                                                                    "'"tabLabel'": '"tabLabel1'"," +
                                                                                                                      "'"value'": '"Value1'"" +
                                                                                                                  "}" +
                                                                                                       "}]" +
                                                                                    "}" +
                                                                        "}]" +
                                                    "}," +
                                                    "'"documents'":[{" +
                                                                        "'"documentId'":'"1'"," +
                                                                                         "'"name'":'"My First DocuSign.docx'"" +
                                                                                                     "}]" +
                            "}";

            // string body = string.Format("Content-Disposition: form-data; boundary={0}", requestBody);
            // set request url, method, body, and headers
            HttpWebRequest request = HttpResponseHelper.initializeRequest(
                                                                        HttpResponseHelperConstants.REQUEST_ACCEPT_JSON,
                                                                        HttpResponseHelperConstants.CONTENT_TYPE_MULTIPART,
                                                                        url,
                                                                        "POST",
                                                                        requestBody,
                                                                        null,
                                                                        CredentialsEntity.Instance);
            // read the http response
            string response = HttpResponseHelper.getResponseBody(request);
        }        
        catch (WebException ex)
        {
            WebResponse errorResponse = ex.Response;
            using (Stream responseStream = errorResponse.GetResponseStream())
            {
                StreamReader reader = new StreamReader(responseStream, Encoding.GetEncoding("utf-8"));
                String errorText = reader.ReadToEnd();
                // log errorText
            }
            throw;
        }
        catch (Exception ex)
        {
            throw new DocuSignAccountException("Error when tried to create an envelope", ex);
        }

}

我使用以下示例演示Docusign官方网页的函数:initializeRequest()和getResponseBody()。My HttpWebRequest.Accept="application/json";HttpWebRequest.ContentType="多部分/表单数据";

我需要帮助来弄清楚我在Json和/或C#代码中遗漏了什么。

Docusign错误:“;“信封_IS_不完整”;当I';我正试图创建一个信封C#和Json

json示例只是试图修改模板角色本身,而不是填写发送模板的数据。尝试将服务器模板覆盖在上面的复合模板,使用以下内容,但输入模板ID和收件人/角色信息(并添加用于嵌入签名的客户端用户ID):

{
  "emailSubject": "DocuSign API - Composite Templates",
  "emailBlurb": "Composite Templates - Server Template Sample",
  "status": "sent",
  "compositeTemplates": [
    {
      "serverTemplates": [
        {
          "sequence": "2",
          "templateId": "REPLACEME"
        }
      ],
      "inlineTemplates": [
        {
          "sequence": "1",
          "recipients": {
            "signers": [
              {
                "email": "firstrecipient@email.com",
                "name": "John Doe",
                "recipientId": "1",
                "roleName": "RoleOne"
              }
            ]
          }
        }
      ]
    }
  ]
}