If I understand correctly, you are asking how to make an HTTP request with HttpClient and deserialize the results. The official documentation covers this subject very very well.
Make HTTP requests using IHttpClientFactory in ASP.NET Core
Tutorial: Create a web API with ASP.NET Core
public async Task OnPostAsync()
{
UserModel model = new UserModel()
{
UserName = "Hello",
Password = "password"
};
var httpClient = _httpClientFactory.CreateClient();
using var httpResponseMessage =
await httpClient.PostAsJsonAsync("https://localhost:7190/api/Login", model);
httpResponseMessage.EnsureSuccessStatusCode();
AuthenticationResponse response = await httpResponseMessage.Content.ReadFromJsonAsync<AuthenticationResponse>();
}
public class AuthenticationResponse
{
public string message { get; set; }
public bool status { get; set; }
public Data data { get; set; }
public string statusCode { get; set; }
}
public class Data
{
public string userID { get; set; }
public string userName { get; set; }
public string userRole { get; set; }
public string environment { get; set; }
}