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.

Rijwan AnsariRank #82 · 24.2K reputationPosted Mar 26, 2021, 6:18 AM EDT
Rijwan AnsariRank #82 · 24.2K reputationPosted Mar 26, 2021, 6:20 AM EDT
Sujeet RamanRank #1,329 · 1.3K reputationPosted Mar 26, 2021, 7:58 AM EDT
Kiran MohantyRank #821 · 2.8K reputationPosted Mar 26, 2021, 8:55 AM EDT
Sujeet RamanRank #1,329 · 1.3K reputationPosted Mar 26, 2021, 9:08 AM EDT