My angular http request body params are not binding to my api. This is my api which Iam trying to bind body directly without using any complex parameter like class.
public async Task<Object> RejectRequest([FromBody] int RequestId, string
Reason){
}
This is my angular http request:-
rejectRequest(data): any {
var body = JSON.stringify(data);
const httpOptions = {
headers: new HttpHeaders({
'Content-Type': 'application/json',
'Authorization': `Bearer ${localStorage.getItem('token')}`
}),
responseType: 'text' as 'text'
};
return this.http.post('/api/Dashboard/RejectRequest',body, httpOptions)
}
my body request is :-
{
"requestid":"45",
"reason":"dfgsdf"
}
{ "requestid":"45", "reason":"dfgsdf" }i have attached json in question. iam getting it binded if iam using models in api as params. but if direclty used primitive params i cant get it binded