Quantcast
Channel: Web API
Viewing all articles
Browse latest Browse all 4850

OData action with WebAPI?

$
0
0

I define an EDM model like:

            var action = builder.EntityType<TOrg>()
                .Action("GetOrganizationByTypeAndStatus");
            action.Parameter<string[]>("type");
            action.Parameter<string[]>("status");
            action.ReturnsCollectionFromEntitySet<TOrg>("TOrgs");

The controller code looks like:

        [HttpPost]
        [EnableQuery]
        public IQueryable<TOrg> GetOrganizationByTypeAndStatus(ODataActionParameters parameters)
        {
            var typeList = new List<string>((string[])parameters["type"]);
            var statusList = new List<string>((string[])parameters["status"]);

            return db.TOrgs.Where(o => typeList.Contains(o.fOrgType) && statusList.Contains(o.fStatus)).OrderByDescending(x => x.fStatusDate);
        }

But when I use Fiddler to execute the request:

POST http://localhost:50056/odata/TOrgs/GetOrganizationByTypeAndStatus HTTP/1.1
User-Agent: Fiddler
Host: localhost:50056
Content-Length: 51

{"type" : ["01"], "status" : ["ORG", "RGD", "INC"]}

I get a 404 error. 

Ideas on what part of this I don't understand?

Thank you.


Viewing all articles
Browse latest Browse all 4850

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>