[HttpPost("xxxxxxxxxx")]
[Authorize(Roles = "xxxxxxxxx")]
public IActionResult Post([FromBody]xxxxxxx xxxxxxxxxxxxxx)
{
if (s == null)
{
}
}
the above code is attribute Authorize(Roles ="Director"). My application roles are student, Director,Manager. This particular method has to be accessed only by director, and for the above method It is giving me back 401 unauthorized.
export function xxxxxxxxxxxx(token, formValues) {
return axios.post(`${ROOT_URL}/xxxxxxx/xxxxxxxx`, formValues);
}
}
I am not sure how to send bearer token in header through axios call.
If sending requests to a Web API controller, you need to send the authorization token in the header Authorization, eg : "Bearer xxxxxxxx".