I am using asp.net core web api. below is my simple post function which is having a single string parameter. The problem is when I use [FromBody] the string stays null. I am using PostMan to test my service. I want raw data to pass from client to my controller. In Postman I am selecting body type RAW and
I set the header Content-Type text/plain. The Raw Body contains Just "Hello World" string.
[HttpPost]
[Route("hosted-services/tokenize-card")]
public IActionResult Test([FromRoute]decimal businessKey,[FromBody] string body)
{
var data = businessKey;
return new JsonResult("Hello World");
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…