I'm trying to make a web api using the new .NET Core. But having some trouble using the the [HttpPost]
. When I use postman, it doesn't return anything. Also when I put a breakpoint on the return line it's never hit.
This is my method in the controller:
// POST api/values
[HttpPost]
public IEnumerable<string> Post([FromBody]string value)
{
return new string[] { "value1", "value2" };
}
The GET method is working:
// GET api/values
[HttpGet]
public IEnumerable<string> Get()
{
return new string[] { "value1", "value2" };
}
It returns a Json value and when I place a breakpoint it hits.
I think I have to add something somewhere else to map the post to this method, but I can't figure out what.
Update: The post request
This is the Post code generated in Postman:
POST /api/values HTTP/1.1
Host: localhost:60228
Content-Length: 0
Cache-Control: no-cache
Postman-Token: 295f7c89-f5a8-d6cd-d679-ae907b010550
firstName:jantje