Showing posts with label Web API calling c# with byte data. Show all posts
Showing posts with label Web API calling c# with byte data. Show all posts

Monday 14 December 2015

Web API calling c# with byte data

            HttpClient client = new HttpClient();
            client.BaseAddress = new Uri("http://localhost/");
            client.DefaultRequestHeaders.Accept.Add(
               new MediaTypeWithQualityHeaderValue("application/json"));
            byte[] fileBytes = File.ReadAllBytes(@"D:\\byteCompress1.txt");
            InPutData inp = new InPutData();
            inp.inputarray = fileBytes;
            inp.printerName = "GF Printer";
            inp.docName = "test";
            var response = client.PostAsJsonAsync("print/sendprint", inp).Result;
           if (response.IsSuccessStatusCode)
            {
                ///result is true
            }
            else
            {
              // result false
            }