So I'm trying to map this method as an Odata function ...
[HttpGet]
[EnableQuery]
public IHttpActionResult ForBuyerOrganisations([FromUri]int[] orgIds)
{
// this returns IQueryable<TRDetails>
// i tried throwing a ToList on there too to ensure it works and it does
var result = service.ForBuyerOrgs(orgIds);
return Ok(result);
}
I have mapped it like this ...
var forBuyers = Builder.EntityType<TRDetails>().Collection.Function("ForBuyerOrganisations");
forBuyers.ReturnsCollection<TRDetails>();
forBuyers.CollectionParameter<int>("orgIds");
... I also tried this ...
var forBuyers = Builder.EntityType<TRDetails>().Collection.Function("ForBuyerOrganisations");
forBuyers.ReturnsCollectionFromEntitySet<TRDetails>();
forBuyers.CollectionParameter<int>("orgIds");
I can call it with the url:
~/TRDetails/ForBuyerOrganisations?orgIds=1
The Problem:
The request executes my code and returns from this method, then the client gets a 406.
Any Ideas?
Yes. @Ouyang indicates the config error. Besides, as I seem, there are other four errors:
you should call the function with namespace-qualified.
TRDetails/Namespace.ForBuyerOrganisations(...)
you should set the argument as list, because you config it as collection.
So, the following request is sample request:
~/TRDetails/Default.ForBuyerOrganisations(orgIds=[5,4,2,3,1])