Click here to Skip to main content
15,901,035 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
So I have somebody with some properties in my web API .net 5 c#

body payload good:
{
   street_address: "Something",
   city_town: "Something"
}


My problem is if someone takes my API and writes properties by hand don't use swagger definition and send me request like this, where properties are not correct naming:

body payload BAD:
{
   street_addres: "Something",
   city_tawn: "Something"
}


How should I validate this in my web API?

TNX

What I have tried:

I tried validation, and modelstate.isvalid nothing helps..
Posted
Updated 24-Jan-22 1:22am
v2

1 solution

body payload good:

{
   street_address: "Something",
   city_town: "Something"
}




body payload BAD:

{
   street_addres: "Something",
   city_tawn: "Something"
}
 
Share this answer
 
Comments
Richard Deeming 24-Jan-22 7:20am    
If you want to update your question to add missing information, then click the green "Improve question" link and update your question.

Do not post your update as a "solution" to your question.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900