I tried below code to read username/password from body, but all i am getting is 'object reference not set to an instance of an object' Code of API:
[Route("api/login_test")]
[HttpGet]
public object login_test([FromBody] string[] Username_Password])
{
string UsernameOrEmail_address, Password;
UsernameOrEmail_address = Username_Password[0];
Password = Username_Password[1];
return UsernameOrEmail_address + " " + Password;
}
by Changing the Http request it worked, replacing from HttpGet to HttpPost
[Route("api/login_test")]
[HttpPost]
public object login_test([FromBody] string[] Username_Password])
{
string UsernameOrEmail_address, Password;
UsernameOrEmail_address = Username_Password[0];
Password = Username_Password[1];
return UsernameOrEmail_address + " " + Password;
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.