private string GetResponse(IWebHttpWebRequest request)
        {
            var result = string.Empty;

            try
            {
                //var response = await request.GetResponseAsync();
                request.GetResponse();
                var statusCode = request.StatusCode;
                if (statusCode == HttpStatusCode.OK || statusCode == HttpStatusCode.Created)
                {
                    using (var stream = request.GetResponseStream())
                    {
                        if (stream != null)
                        {
                            var buffer = new byte[2048];
                            using (var desinationStream = new MemoryStream())
                            {
                                int bytesRead;
                                do
                                {
                                    bytesRead = stream.Read(buffer, 0, 2048);
                                    desinationStream.Write(buffer, 0, bytesRead);
                                } while (bytesRead != 0);

                                result = Encoding.UTF8.GetString(desinationStream.ToArray());
                            }
                        }
                    }
                }
                else
                {
                    Log.Warning("Received {StatusCode} from server", statusCode);
                    return("Error");
                }
            }
            catch (Exception ex)
            {
                Log.Error(ex, "Error occured while waiting for web response");
                throw;
            }
            return(result);
        }
        private async Task<string> GetResponse(IWebHttpWebRequest request)
        {
            var result = string.Empty;
            try
            {
                //var response = await request.GetResponseAsync();
                request.GetResponse();
                var statusCode = request.StatusCode;
                if (statusCode == HttpStatusCode.OK)
                {
                    using (var stream = request.GetResponseStream())
                    {
                        if (stream != null)
                        {
                            //var buffer = new byte[2048];
                            using (var desinationStream = new MemoryStream())
                            {
                                await stream.CopyToAsync(desinationStream);
                                //stream.CopyTo(desinationStream);

                                result = Encoding.UTF8.GetString(desinationStream.ToArray());
                            }
                        }
                    }
                }
                else
                {
                    Log.Warning("Got response {StatusCode} from server", statusCode);
                    return "Error";
                }
            }
            catch (Exception ex)
            {
                Log.Error(ex, "Error occured while waiting for web response");
            }
            return result;
        }
        private string GetResponse(IWebHttpWebRequest request)
        {
            var result = string.Empty;
            try
            {
                //var response = await request.GetResponseAsync();
                request.GetResponse();
                var statusCode = request.StatusCode;
                if (statusCode == HttpStatusCode.OK || statusCode == HttpStatusCode.Created)
                {
                    using (var stream = request.GetResponseStream())
                    {
                        if (stream != null)
                        {
                            var buffer = new byte[2048];
                            using (var desinationStream = new MemoryStream())
                            {
                                int bytesRead;
                                do
                                {
                                    bytesRead = stream.Read(buffer, 0, 2048);
                                    desinationStream.Write(buffer, 0, bytesRead);
                                } while (bytesRead != 0);

                                result = Encoding.UTF8.GetString(desinationStream.ToArray());

                            }
                        }
                    }
                }
                else
                {
                    Log.Warning("Received {StatusCode} from server", statusCode);
                    return "Error";
                }
            }
            catch (Exception ex)
            {
                Log.Error(ex, "Error occured while waiting for web response");
                throw;
            }
            return result;
        }