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

above code I am using to connect with DocuSign for signing document. but this a development base URL and resource path. our client has paid account with DocuSign .they are using DSA web app and Client App.so I need to replace the development credential to their original credential . from where I get the base URL and Resource path .

2 Answers 2

0

The DSA (DocuSign Signature Appliance) is usually provisioned as on-premises hardware. So you will need to coordinate with the administrator for the DSA to learn its IP address or DNS name.

If the DSA Web App is being used, it is usually provisioned as an on-premises software installation on a Windows server. So you'll again need to coordinate with the administrator for the installation.

If you're stuck, please contact DocuSign support for help.

2
  • Everything already installed and they are using. but for new external application we need to get details like Base URL and Resource path. in DSA Webapp where we get the details
    – Sudeep
    Jun 8, 2021 at 12:03
  • The DSA Web App base url depends on how it was installed by your server's administrator. I suggest you contact DocuSign Support.....
    – Larry K
    Jun 9, 2021 at 10:02
0

It would be best to have the DSA IP address or the server's full name, but you cannot collect it from the WebApp. You need to replace the "prime-dsa-devctr.docusign.net" with the customer's IP/full name.

They should know what is the IP/name as you configure it in the DSA client.

To open a case with the DSA support, please send an email: [email protected]. Try to provide as much information as possible, such as serial number, server version, etc.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.