I'm trying to retrieve a signed document via RestAPI v2 with below code.
url = baseURL + "/accounts/" + "3602fbe5-e11c-44de-9e04-a9fc9aa2aad6" + "/envelopes/" + envId + "/documents/combined";
HttpWebRequest request4 = (HttpWebRequest)WebRequest.Create(url);
request4.Method = "GET";
request4.Headers.Add("X-DocuSign-Authentication", authHeader);
request4.Accept = "application/pdf";
request4.ContentType = "application/json";
request4.ContentLength = 0;
HttpWebResponse webResponse4 = (HttpWebResponse)request4.GetResponse();
StreamReader objSR = new StreamReader(webResponse4.GetResponseStream());
StreamWriter objSW = new StreamWriter(@"C:\Users\reddy\Desktop\Docusign\test_" + envId + ".pdf");
objSW.Write(objSR.ReadToEnd());
objSW.Close();
objSR.Close();
With above code, I'm able to save a PDF file but something is not right. Can someone help me fix my buggy code.
Option 1: You can simply use the System.Net.WebClient class
Option 2 : Copy the input stream to the output FileStream
Option 3 : Using the DocuSign C# SDK
See full code here
Also see this answer