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); } }
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); }