Exemplo n.º 1
0
        public void CallDSAPI_Click(object sender, EventArgs e)
        {
            dsParameters    parameters         = new dsParameters();
            dsResponse      responseFromServer = new dsResponse();
            DSServiceBroker dsServiceBroker    = new DSServiceBroker();

            parameters.dsmethodURI   = TbLoginURI.Text;
            parameters.restEndpoint  = TbURI.Text;
            parameters.userName      = TbUserName.Text;
            parameters.password      = TbPassword.Text;
            parameters.integratorKey = TbIntKey.Text;

            responseFromServer = dsServiceBroker.CallDSAPI(parameters);

            if (responseFromServer.responseOK)
            {
                TbResults.Text = responseFromServer.response;
            }
            else
            {
                TbResults.Text = responseFromServer.responseError + "\n" + responseFromServer.responseErrorResponse;
            }
        }
Exemplo n.º 2
0
        public dsResponse CallDSAPI(dsParameters callParameters)
        {
            dsResponse responseFromServer = new dsResponse();

            string requestURI = callParameters.restEndpoint + callParameters.dsmethodURI;

            try
            {
                WebRequest webRequest = WebRequest.Create(requestURI);

                webRequest.Headers.Add("X-DocuSign-Authentication", DSUtilities.XDSAuthHeaderValue(callParameters.userName, callParameters.password, callParameters.integratorKey));
                webRequest.Method = "GET";

                WebResponse response = webRequest.GetResponse();


                responseFromServer.responseCode = (((HttpWebResponse)response).StatusCode.ToString());
                responseFromServer.responseOK   = true;
                Stream       responseStream = response.GetResponseStream();
                StreamReader reader         = new StreamReader(responseStream);

                responseFromServer.response = reader.ReadToEnd();

                response.Close();
            }
            catch (WebException ex)
            {
                responseFromServer.responseOK            = false;
                responseFromServer.responseError         = ex.Message;
                responseFromServer.responseErrorResponse = ex.Response.ToString();
            }
            finally
            {
            }

            return(responseFromServer);
        }