Exemplo n.º 1
0
        public static async Task PostImage(string url, ImgAPI imgApi)
        {
            var path = url + @"/api/Image";
            HttpResponseMessage Response;

            using (HttpClient client = new HttpClient())
            {
                Response = await client.PostAsJsonAsync("http://" + path, imgApi);
            }
        }
Exemplo n.º 2
0
        public static async Task <bool> PostImage(string url, ImgAPI imgApi)
        {
            var path = url + @"/api/Image";
            HttpResponseMessage Response;

            try
            {
                using (HttpClient client = new HttpClient())
                {
                    Response = await client.PostAsJsonAsync("http://" + path, imgApi);
                }
                if (Response.IsSuccessStatusCode)
                {
                    return(true);
                }
            }
            catch (Exception)
            {
                return(false);
            }
            return(false);
        }