0

我正在使用 DocuSign REST API 在 C# MVC 应用程序中集成协议签名。我已经获得了几乎所有按我想要的方式工作的功能,但是我在 DocuSign iframe 中完成签名后加载的页面遇到了一些问题。我在模板身份验证之外的项目中创建了一个视图,并将 XML“returnUrl”标记指向它。

它现在加载该页面,但是问题来自尝试传入多个参数。理想情况下,我想传入 3 个不同的字符串,但是当我尝试在 URL 中包含所有 3 个查询字符串参数时,XML 请求错误。一个它通过就好了。

当前代码不会出错并允许在将单个参数传递到签名后页面时完成签名过程:

string reqBody = "<recipientViewRequest xmlns=\"http://www.docusign.com/restapi\">" +
                "<authenticationMethod>email</authenticationMethod>" +
                    "<email>" + model.TSM.Email + "</email>" +      // NOTE: Use different email address if username provided in non-email format!
                    "<returnUrl>https://maaxspasportal.com/TerritorySalesManagement/AfterSigningLandingPage?contactName=" + model.ContactName.Replace(" ", "%20") + "</returnUrl>" +  // username can be in email format or an actual ID string
                    "<clientUserId>1</clientUserId>" +
                    "<userName>" + model.TSM.Name + "</userName>" +
                    "</recipientViewRequest>";

使 XML 请求无效并返回错误的代码:

            string contactName = model.ContactName.Replace(" ", "%20");
            string companyName = model.CompanyName.Replace(" ", "%20");
            string contactEmail = model.Dealer.Email.Replace(" ", "%20");

            string reqBody = "<recipientViewRequest xmlns=\"http://www.docusign.com/restapi\">" +
                "<authenticationMethod>email</authenticationMethod>" +
                    "<email>" + model.TSM.Email + "</email>" +      // NOTE: Use different email address if username provided in non-email format!
                    "<returnUrl>https://maaxspasportal.com/TerritorySalesManagement/AfterSigningLandingPage?contactName=" + contactName + "&companyName=" + companyName + "&contactEmail=" + contactEmail + "</returnUrl>" +  // username can be in email format or an actual ID string
                    "<clientUserId>1</clientUserId>" +
                    "<userName>" + model.TSM.Name + "</userName>" +
                    "</recipientViewRequest>";

这是我收到的错误:

<errorDetails xmlns="http://www.docusign.com/restapi" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"><errorCode>INVALID_REQUEST_BODY</errorCode><message>The request body is missing or improperly formatted. An error occurred while parsing EntityName. Line 1, position 271.</message></errorDetails>

有没有人遇到过这个?有没有更好的方法将参数传递给我的“returnUrl”页面?谢谢你的帮助。

4

1 回答 1

2

尝试对 URL 中的 & 符号 ( & ) 进行编码。例如,尝试将returnUrl设置为如下内容:

<returnUrl>https://maaxspasportal.com/TerritorySalesManagement/AfterSigningLandingPage?contactName=John%20Smith&#038;companyName=ABC_Company&#038;contactEmail=johnsmith@test.com</returnUrl>

请注意,我已将每次出现的&替换为& ;( 8; 之间没有空格)

更新: 这是获取收件人 URL 的完整 XML 请求:

POST https://{{env}}.docusign.net/restapi/{{version}}/accounts/{{acctId}}/envelopes/{{envelopeId}}/views/recipient

<recipientViewRequest xmlns="http://www.docusign.com/restapi">
  <authenticationMethod>Email</authenticationMethod>
  <email>johnsmith@test.com</email>  
  <returnUrl>https://maaxspasportal.com/TerritorySalesManagement/AfterSigningLandingPage?contactName=John%20Smith&#038;companyName=ABC_Company&#038;contactEmail=johnsmith@test.com</returnUrl>
  <clientUserId>123</clientUserId>
  <userName>John Smith</userName>
</recipientViewRequest>

返回的响应如下:

<viewUrl 
    xmlns="http://www.docusign.com/restapi" 
    xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
    <url>https://demo.docusign.net/Member/StartInSession.aspx?t=87aaeca6-77cd-44f5-9ec0-8384270f52e7</url>
</viewUrl>

在新浏览器中,我导航到响应的url元素中指定的 URL 并完成/确认签名。提交信封后,我被重定向到我之前在请求中指定的重定向页面。该页面似乎成功解析了所有 3 个查询字符串参数:

在此处输入图像描述

于 2013-10-24T23:17:29.177 回答