DocuSign付费账号DSA生产环境Base URL及资源路径获取咨询
问题相关代码(C#)
using RestSharp; using System; using System.IO; using Newtonsoft.Json.Linq; namespace DSARestCsharpSample { class Program { static void Main(string[] args) { String baseURL = "https://prime-dsa-devctr.docusign.net:8081"; String resourcePath = "sapiws/v1/digital_signature"; String apiUrl = baseURL + "/" + resourcePath; var client = new RestClient(apiUrl); var request = new RestRequest(Method.PUT); request.AddHeader("content-type", "application/json"); request.AddHeader("authorization", "Basic " + DSABasicAuthorizationString("{dsa-user-name}", "{dsa-user-password}")); // "digital_signature" request body as Json formated String (use JavaScriptSerializer or Newtonsoft.Json to build from object) String DigSigRequestBody = "{ \"CreateAndSignField\" : " + //structure name specifies the operation / function "{ \"file\": " + "\"" + File2Base64String("c:\\tmp\\PurchaseOrder.pdf") + "\", " + "\"fileType\": \"PDF\", " + "\"x\": \"91\", " + "\"y\": \"164\", " + "\"width\": \"113\", " + "\"height\": \"38\", " + "\"page\": \"1\", " + "\"timeFormat\": \"h:mm:ss\", " + "\"dateFormat\": \"dd/MM/yyyy\", " + "\"appearance\": [\"GRAPHICAL_IMAGE\", \"SIGNED_BY\", \"TIME\"]" + "}" + "}"; request.AddParameter("application/json", DigSigRequestBody, ParameterType.RequestBody); IRestResponse response = client.Execute(request); JObject joResponse = JObject.Parse(response.Content); Base64String2Path(joResponse["signedFile"].Value<string>(), "c:\\tmp\\PurchaseOrder.DSA-REST-SIGNED.pdf"); } private static void Base64String2Path(string Base64String, string FilePath) { Byte[] bytes = Convert.FromBase64String(Base64String); File.WriteAllBytes(FilePath, bytes); } private static String File2Base64String(String FilePath) { Byte[] bytes = File.ReadAllBytes(FilePath); String fileB64Data = System.Convert.ToBase64String(bytes); return fileB64Data; } private static String DSABasicAuthorizationString(String username, string password) { var DSABasicAuthorizationBytes = System.Text.Encoding.UTF8.GetBytes(username+":"+password); return System.Convert.ToBase64String(DSABasicAuthorizationBytes); } } }
解答
以下是DSA生产环境Base URL和资源路径的获取方式:
- 直接向客户方的DSA运维/管理员索要即可:客户已经完成了DSA Web App和Client App的生产部署,Base URL就是他们部署的DSA服务对外暴露的API根地址,一般格式为
https://<客户DSA生产域名或IP>:<配置端口>,默认端口如果没有做特殊修改通常为8081,部分客户会调整为HTTPS默认的443端口,以客户实际运维配置为准。 - 资源路径
sapiws/v1/digital_signature是DSA对应版本REST API的固定路径,只要生产环境DSA版本和你开发时使用的版本一致,该路径不需要修改,仅替换Base URL即可。 - 额外注意:除了地址之外,还需要向客户索要生产环境的DSA授权账号密码,替换代码中的
{dsa-user-name}和{dsa-user-password}占位符,确保该账号有调用签名接口的对应权限。 - 如果客户管理员暂时找不到配置记录,可以让他们查看本地正常访问的DSA Web App地址,去掉地址中的页面路径部分保留根地址和端口即可,例如Web访问地址为
https://dsa.customer.com:8081/dsa/web/index.html,对应的Base URL就是https://dsa.customer.com:8081。
内容的提问来源于stack exchange,提问作者Sudeep
相关产品推荐
相关产品推荐

