public PeopleVM2 Method1GetPeopleV2() { PeopleVM2 people = new PeopleVM2(); try { using (var client = new HttpClient()) { string GetRequestUri = String.Format("{0}/api/people/", baseUri); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/vnd.meijer.cart.cart-v2.0+json")); var result = client.GetAsync(GetRequestUri).Result; if (result.IsSuccessStatusCode) { string resultContent = result.Content.ReadAsStringAsync().Result; people = JsonConvert.DeserializeObject <PeopleVM2>(resultContent); } else { throw new Exception(String.Format("Error Calling /api/people", result.ReasonPhrase)); } } } catch (Exception ex) { } return(people); }
//If you don't set the RouteName property, Web API generates the name. //The default route name is "ControllerName.ActionName". public PeopleVM2 Create(PeopleVM2 person) { return(new PeopleVM2() { Id = person.Id, Url = _UrlHelper.Link("GetPersonByIdV2", new { id = person.Id }), FirstName = person.FirstName, LastName = person.LastName, Mobile = person.Mobile, Telephone = person.Telephone, Website = person.Website }); }