Search code examples
asp.net-web-apiodataasp.net-web-api2

Web API 2: OData 4: Possible bug with GUIDs?


I've updated my solution to use OData v4 for Web API 2 - I was previously usingOData v3. For some reason, some of the routes are giving a 404 error where they were working perfectly fine before. These routes are anything with the entity key/ID.. example:

[EnableQuery]
    public virtual SingleResult<TEntity> Get([FromODataUri] TKey key)
    {

and

public virtual IHttpActionResult Delete([FromODataUri] TKey key)
        {

As I said, they were working perfectly fine before, but now I am getting a 404 for these. Other routes, such as below, are fine:

[EnableQuery]
        public virtual IQueryable<TEntity> Get()
        {

and

public virtual IHttpActionResult Post(TEntity entity)
        {

Note that my entities are sending GUIDs for the ID. Is there maybe a bug with GUIDs in OData 4?


Solution

  • Okay, yes... confirmed as something wrong.. I would say it's a bug.. but maybe MS has some strange reason for it; Anyway, here's a link to the issue on CodePlex:

    https://aspnetwebstack.codeplex.com/workitem/885

    Basically, in OData v3, you would query like this: /odata/Something(guid'some-guid-here'), but in OData 4, it's changed to: /odata/Something(some-guid-here)