Search code examples
odatabreezejaydata

How can I get Breeze to query $metadata instead of Metadata?


I set up my odata service with Node, MongoDB and JayData. When I hit http://localhost:8000/odata/findash.svc/$metadata in my browser I get the metadata exactly as I would expect.

In the browser console I execute this sample code:

var manager = new breeze.EntityManager('odata/findash.svc');
var query = new breeze.EntityQuery()
    .from("accounts");
manager.executeQuery(query).then(function(data){
    console.log(data);
}).fail(function(e) {
    alert(e);  
});

An alert pops up with the message: Error: Metadata query failed for: odata/findash.svc/Metadata; Not Found

The net tab confirms that Breeze is hitting odata/findash.svc/Metadata which produces a 404 instead of odata/findash.svc/$metadata which works fine.

Is there a way to configure this behavior in Breeze or is the problem with my odata setup?


Solution

  • I assume that you meant OData and not JayData in your question. Breeze and JayData are two different products. If not then I'm not sure I understand the question.

    I think that you haven't told breeze to use the OData endpoint. By default breeze uses a WebApi endpoint. You can change this via the breeze.config like this:

    breeze.config.initializeAdapterInstances({
        dataService: "OData", ...
    });
    

    Breeze supports both OData and a WebApi endpoints. The OData endpoint ( per the OData spec) returns metadata from '$metadata". The webApi endpoint returns metadata from 'Metadata'.

    See: http://www.breezejs.com/documentation/odata