Is it possible to retrieve a list of entities as a parameter for an action in c# odata?
Tried the following but it casues the entire controller to not work:
[HttpPost]
[NhSessionManagement()]
[ODataRoute("BatchUpdate")]
public async Task<IHttpActionResult> BatchUpdate(List<Item> items, bool updateDefaultJSONFile)
{
return Ok();
}
This is the config:
{
var action = builder.EntityType<Item>().Collection.Action("BatchUpdate");
action.CollectionParameter<Item>("items");
action.Parameter<bool>("updateDefaultJSONFile");
}
This is how I then send the data:
$http.post(appConfig.serviceUrl + "api/items/Service.BatchUpdate", { items: itemsToUpdate, updateDefaultJSONFile: true}).success(function (data, status, headers, config) {
debug("Successfully saved");
}).error(function (data, status, headers, config) {
debug("Failed to save");
});
In fiddler:
POST http://192.168.20.108/api/items/Service.BatchUpdate HTTP/1.1
Host: 192.168.20.108
Connection: keep-alive
Content-Length: 83114
Pragma: no-cache
Cache-Control: no-cache
Accept: application/json, text/plain, */*
Origin: http://192.168.20.108
Authorization: Bearer ****
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36
Content-Type: application/json;charset=UTF-8
Referer: http://192.168.20.108/
Accept-Encoding: gzip, deflate
Accept-Language: sv-SE,sv;q=0.9,en-US;q=0.8,en;q=0.7
{"items":[{"Key":"helpful","Text":"test"}],"updateDefaultJSONFile":false}