0 Replies Latest reply on Mar 28, 2017 6:54 AM by briane50906161

    C# unable to upload a transient document

    briane50906161 Level 1

      I am trying to upload a transient document in C# and I have not been able to do so.

       

       

      MultipartFormDataContent mycontent = new MultipartFormDataContent();

              string encodedFileName = HttpUtility.HtmlEncode("1-Registration Form.pdf");

              HttpContent fileContent = new ByteArrayContent(System.IO.File.ReadAllBytes(ConfigurationManager.AppSettings["PATH_TO_PR IVATE_STORAGE"] + @"documents\1-Registration Form.pdf"));

              mycontent.Add(new StringContent("application/pdf"), "Mime-Type");

              mycontent.Add(new StringContent(encodedFileName), "File-Name");

              fileContent.Headers.ContentDisposition = new ContentDispositionHeaderValue("form-data")

              {

                  Name = "File",

                  FileName = encodedFileName

              };

                  mycontent.Add(fileContent);

              var objGetData = new Models();

       

       

              var objClient = new RestClient("https://api.na1.echosign.com:443/api/rest/v5");

              var objRequest = new RestRequest("transientDocuments", Method.POST);

              objRequest.AddFile("file", System.IO.File.ReadAllBytes(ConfigurationManager.AppSettings["PATH_TO_PRIVATE_STORAGE"] + @"documents\1-Registration Form.pdf"), "1-Registration Form.pdf");

              objRequest.AddHeader("Access-Token", "MyAPIKeyHere");

              objRequest.RequestFormat = DataFormat.Json;

              objRequest.AddBody(objGetData);

              IRestResponse objResponse = objClient.Execute(objRequest);

              var content = objResponse.Content;

              JObject jsonLinq = JObject.Parse(content);

       

      I get An error saying Bad request.  Any help would be appreciated, I've been at this for a week now.