public static Hero LoadHero(long id) { try { using (var httpClient = new System.Net.Http.HttpClient()) { var api = new DemoWebApi.Controllers.Client.Heroes(httpClient, apiUri); return(api.Get(id)); } } catch (Exception ex) { System.Diagnostics.Trace.TraceError(ex.ToString()); throw; } }
static readonly Uri apiUri = new Uri("http://192.168.1.100:9030/webapi/"); //replace url with what in your dev environment public static Hero[] LoadHeroes() { try { using (var httpClient = new System.Net.Http.HttpClient()) { httpClient.BaseAddress = apiUri; var api = new DemoWebApi.Controllers.Client.Heroes(httpClient); return(api.Get()); } } catch (WebApiRequestException ex) { System.Diagnostics.Trace.TraceError(ex.ToString()); throw; } }