jqgrid posts json data in POST request buffer as
{"headerData": {
"Tasudok": "134",
"Kuupaev": "2015-11-23",
"Dokumnr": "135319"
},
"rowData": {
"Toode":"",
"Kogus":"0.0000",
"Nimetus":"öäölä<a",
"_rowsum":"0.00",
"Id":"1639",
"Dokumnr":"135319",
"_oper":"edit",
"_rowid":"1639"
}
}
Data is posted to ASP.NET MVC4 Web API using URL like API/Entity/someid?culture=en&layout=1
with default routing.
headerData
and rowData
value properties are defined in runtime and can vary.
For example in some call rowData may contain additional properties and some rowData properties may be missing.
culture
and layout
query string paramaters are optional.
How to receive parameters in WebAPI controller ?
I tried
public class EntityController : APIController
{
public class PostParams {
public string culture { get; set; }
public int? layout { get; set; }
}
public HttpResponseMessage Post(string id,
[FromUri]PostParams optionalParams,
[FromBody]IList<NameValue> headerData,
[FromBody]IList<NameValue> rowData )
{ ... }
public class NameValue
{
public string name, value;
}
}
But headerData and rowData are empty. How to get all parameters?