Reputation: 34109
I have a client ( in this case POSTMAN) that is posting collection of object. The properties of the object are not known in advance so I cannot use concrete C# model.
So I am using Dictionary<string,object>
that represent a single object where Key
will be the property name and Value
will be the value of the property. Since client is posting collection i am using List<Dictionary<string,object>>
ISSUE
In controller's action method each dictionary has Key
however corresponding value is NULL
POSTMAN
Fiddler shows
model%5B0%5D.FirstName=foo&model%5B0%5D.LastName=bar&model%5B1%5D.FirstName=james&model%5B1%5D.LastName=smith
Quick watch in model:
I tried using JObject
, ExpandoObject
as model with no luck
Upvotes: 0
Views: 1380
Reputation: 34109
I changed the model type from List<Dictionary<string, object>>
to List<Dictionary<string, string>>
and it worked
[HttpPost]
public IActionResult Update([FromForm]List<Dictionary<string, string>> model)
{
return Ok();
}
Upvotes: 1