I made POST and PUT APIs and now I am doing attribute validation,
Model
public class Model
{
public string user_identifier { get; set; }
public string name { get; set; }
}
Payload in postman
{
"user_identifier": "1234",
"name": "abcd"
}
It works for this, but when I change the type of user_identifier like,
{
"user_identifier": 1234,
"name": "abcd"
}
Postman was giving an automatic 400 error for that attribute, which I don't want because I am doing my own validations, so, I added this to suppress those automatic 400 responses,
services.Configure<ApiBehaviorOptions>(options =>
{
options.SuppressModelStateInvalidFilter = true;
});
Now, when I pass the payload as,
{
"user_identifier": 1234,
"name": "abcd"
}
the payload is considered as null, Can anyone please help me with this problem, and also I think it not good to suppress the automatic responses, an alternative would be appreciated.
Thanks in advance.