Reputation: 1452
I want to pass object as parameter in my web api GET and POST method. My code is,
[HttpGet]
[Route("mytest/list/{model}")]
public IHttpActionResult GetAllTypes(TestModel model)
{
//my logic here
}
When I call this, console get an error its not found. I tried this,
[HttpGet]
[Route("mytest/list/{model?}")]
public IHttpActionResult GetAllTypes(TestModel model)
{
//my logic here
}
But, the parameter object gets null value.
Upvotes: 2
Views: 5880
Reputation: 148744
Don't pass an object via GET.
POST an object and use [HttpPost]
attribute.
If you're really want to do it via GET , you can use this :
[HttpGet]
public IHttpActionResult GetAllTypes([FromUri] TestModel model)
Upvotes: 7