Advertisement
Guest User

Untitled

a guest
Mar 20th, 2019
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. public async Task<IActionResult> Index()
  2. {
  3. Uri BaseAdress = Services.Token.BaseAdress;
  4. string strToken = Services.Token.strToken;
  5. List<FormaPagamentoFinModel> ListaAmbientes;
  6. using (HttpClient httpClient = new HttpClient())
  7. {
  8. httpClient.BaseAddress = BaseAdress;
  9. httpClient.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", strToken);
  10. httpClient.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("Application/Json"));
  11. using (HttpResponseMessage response = await httpClient.GetAsync("/api/FormaPagamentoFin/findAll"))
  12. {
  13.  
  14. response.EnsureSuccessStatusCode();
  15. string resul = await response.Content.ReadAsStringAsync();
  16. ListaAmbientes = JsonConvert.DeserializeObject<List<FormaPagamentoFinModel>>(resul);
  17. }
  18. }
  19. return View(ListaAmbientes);
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement