If not single cuote marks gets you an error en Postmat it is probably something different in our web.api. This is what I got. I hope it will help.
In my web.api .Net Framework 4.61 I am using this packages
Microsoft.AspNet.OData 6.1.0
Microsoft.Data.OData 5.8.2
Microsoft.OData.Core 7.2.0
Microsoft.OData.Edm 7.2.0
Sample Code
Model
public class Customer
{
public Guid CustomerId { get; set; }
public string CustomerName { get; set; }
}
Controller
using System.Web.Http;
using System.Web.OData;
using System.Web.OData.Routing;
public class CustomerController : ODataController
{
[HttpGet]
[EnableQuery()]
[ODataRoute(“Customer”)]
public IHttpActionResult GetAll()
{
List customers = new List();
customers.Add(new Customer { CustomerId = new Guid(“14cf2286-83cb-4171-9cb3-3138997a54a3”), CustomerName = “Carlos” });
customers.Add(new Customer { CustomerId = new Guid(“a3e722f9-65e4-44f7-8253-a3da62bc7b7f”), CustomerName = “Mentalengine” });
return Ok(customers);
}
}
WenApiConfig GetEdmModel()
builder.EntitySet<Customer>("Customer");
When using Postman
GET
http://localhost:64481/odata/Customer
Will Return:
{
“@odata.context”: “http://localhost:64481/odata/$metadata#Customer”,
“value”: [
{
“CustomerId”: “14cf2286-83cb-4171-9cb3-3138997a54a3”,
“CustomerName”: “Carlos”
},
{
“CustomerId”: “a3e722f9-65e4-44f7-8253-a3da62bc7b7f”,
“CustomerName”: “Mentalengine”
}
]
}
GET
http://localhost:64481/odata/Customer?$filter= CustomerId eq a3e722f9-65e4-44f7-8253-a3da62bc7b7f
Will Return
{
“@odata.context”: “http://localhost:64481/odata/$metadata#Customer”,
“value”: [
{
“CustomerId”: “a3e722f9-65e4-44f7-8253-a3da62bc7b7f”,
“CustomerName”: “Mentalengine”
}
]
}
BTH when trying using single cuote marks when filtering CustomerId I got an error.