Using BreezeJS/Angular/WebAPI(OData), I have set up a project where I can call a GET with:
breeze.EntityQuery
.from(resource)
.using(manager)
.execute()
.then(function (data) {
deferred.resolve(data.results);
});
However, when I attempt to save changes or create a new entity with:
var type = manager.metadataStore.getEntityType(model);
type.setProperties({
autoGeneratedKeyType: breeze.AutoGeneratedKeyType.KeyGenerator
});
var newM = manager.createEntity(type, m);
manager.saveChanges().then(function () { alert('success'); }, function (error) { prompt("", JSON.stringify(error)); });
I get the error:
"No HTTP resource was found that matches the request URI 'http://localhost:57508/odata/odata/Models'"
This is weird because the URL is wrong. It has the service url plus an extra 'odata'.
My AngularJS factory is pretty simple:
app.factory("EntityManagerFactory", ['breeze', function (breeze) {
configureBreeze();
var serviceRoot = window.location.protocol + '//' + window.location.host + '/';
var serviceName = serviceRoot + 'odata/';
var factory = {
manager: newManager,
serviceName: serviceName,
metadataStore: {}
};
return factory;
function configureBreeze() {
// use Web API OData to query and save
breeze.config.initializeAdapterInstance('dataService', 'webApiOData', true);
// convert between server-side PascalCase and client-side camelCase
// breeze.NamingConvention.camelCase.setAsDefault();
}
function newManager() {
var mgr = new breeze.EntityManager(serviceName);
mgr.fetchMetadata().then(function () {
//var modelType = manager.metadataStore;
});
return mgr;
}
}]);
I'm not really sure where else to look for the extra 'odata' that's being added to the generated URL. Removing the 'odata' from the serviceName then prevents GET's working.
Thanks very much.