I have this peace of code :
function getSopMatches(data) {
return EntityQuery.from('GetSopMatches')
.withParameters({
$method: 'POST',
$encoding: 'JSON',
$data: data
})
.using(manager).execute()
.then(success)
.catch(_queryFailed);
function success(response) {
return response.results;
}
}
and it is called through this :
playerService.getSopMatches({ playerId: vm.player.id, competitionId: career.competitionId, seasonId: career.seasonId, teamId: career.teamId }).then(function (results) { //do something with it });
In my MVC controller (BreezeController) the method is like :
[HttpPost]
public IQueryable<object> GetSopMatches(SopMatch sop)
{
//this method is not called, I get a 405 Method not Allowed
}
Somehow, the actual call is a GET, instead of a POST and therefore I get the 405 Method not Allowed error message.
I have other peaces of code in the same project (client side javascript/breeze calls and server side mvc controller methods) that do work.
Does anybody knows what I'm doing wrong, or why it is changed to a GET method ?
After a day of trying and failing, I found a solution.
It appeared that in the angular controller I was injecting breeze, and that was causing the issue. When breeze is injected into the controller or service, it messes up the URL of the POST and therefore you receive a 405 (because the URL is changed).