Hi
I have an api post method. I don't have any UI to use that api so i need to show my error message in postman. If I miss one property the missing property error message should be displayed in postman.i confused with many post in internet.
my post method
- [HttpPost("api/Student/Check")]
- public async Task Check([FromBody] students input)
- {
- var result = await _students.studentAsync(input);
- return Ok(result);
- }
- my model
- public class students
- {
- [JsonProperty("studentid")]
- public int studentid{ get; set; }
- [JsonProperty("studentname")]
- public int studentname{ get; set; }
- [JsonProperty("studentage")]
- public int studentage{ get; set; }
- }
- }
I should get like:
Expected Result: Status code is 400 bad request and response should be as below:
student id is required.This cannot be null or blank.
student name is required.This cannot be null or blank
student age field is required.This cannot be null or blank.