4
My problem is this: I am consuming a Webapi with the method PostAsJsonAsync
In this call I am receiving a Token for authentication in the ADMIN methods of an EAD platform that we are working on.
So far so good. When I call the ADMIN methods sending the Token returned in the login method, it is returning as "Unauthorized". Follows part of the code that is not working:
response = null;
vAuth_token = retorno.authentication_token;
client.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("X-Auth-Token", vAuth_token);
response = await client.GetAsync("api/admin/users");
if (response.IsSuccessStatusCode)
{
//HTTP GET
try
{
Usuarios usuarios = await response.Content.ReadAsAsync<Usuarios>();
}
catch (Exception erro)
{
}
}
Thanks brazilianldsjaguar, but continues with the same problem. I do not know if I did not understand right. Where I was in trouble I switched to client.DefaultRequestHeaders.Add("X-Auth-Token", vAuth_token); . Is there anything else missing?
– Vitor Salotti