Hi Below is my current code:
var url = "https://localhost:44332/token";
var login = new Login()
{
username = "test@gmail.com",
password = "Password@1",
grant_type = "password"
};
using (var client = new HttpClient())
{
httpResponseMessage = await client.PostAsJsonAsync(url, login);
if (httpResponseMessage.IsSuccessStatusCode)
{
var token = httpResponseMessage.Content.ReadAsStringAsync();
}
}
My error is that 400: Bad Request, whenever i make the API call. If i use postman, its working, The following is what i put in POSTMAN body: "username=test@gmail.com&password=Password@1&grant_type=password"
Many Thanks in advance if anyone can correct me!