I am trying to consume Redmine API from an angularjs project.
I ended up using jsonp in order to solve CORS problem.
I receive 404 when calling this:
var url = 'http://muser:mpasswd@myredmine/issues.json?callback=displayIssues';
$http({
method: 'JSONP',
url: url
}).
success(function (data, status) {
console.log("success");
console.log(data);
}).
error(function (data, status) {
console.log("Error: " + status);
});
...
function displayIssues(issues) {
console.log('displayIssues');
...
}
But when I call the same url with Postman, it works.
Why do I receive this 404?
here is my console:
GET http://muser:mpasswd@myredmine/issues.json?callback=displayIssues jsonpReq @ angular.js:8576(anonymous function) @ angular.js:8420sendReq @ angular.js:8291serverRequest @ angular.js:8025wrappedCallback @ angular.js:11498wrappedCallback @ angular.js:11498(anonymous function) @ angular.js:11584Scope.$eval @ angular.js:12608Scope.$digest @ angular.js:12420Scope.$apply @ angular.js:12712(anonymous function) @ angular.js:18980x.event.dispatch @ jquery-2.0.3.min.js:5y.handle @ jquery-2.0.3.min.js:5
authentication.service.js:100 Error: 404
Rest API and jsonp are both enabled in the admin->setting->auth
I also tried:
var url = 'http://muser:mpasswd@myredmine/redmine/issues.json&callback=JSON_CALLBACK';
$http.jsonp(url, {
params: {
callback: 'JSON_CALLBACK',
format: 'json'
}
}).success(function (data) {
console.log('ok');
}).error(function (data) {
console.log('error: ' + JSON.stringify(data));
});
getting this:
GET http://muser:mpasswd@myredmine/issues.json&callback=angular.callbacks._0?callback=JSON_CALLBACK&format=json jsonpReq @ angular.js:8576(anonymous function) @ angular.js:8420sendReq @ angular.js:8291serverRequest @ angular.js:8025wrappedCallback @ angular.js:11498wrappedCallback @ angular.js:11498(anonymous function) @ angular.js:11584Scope.$eval @ angular.js:12608Scope.$digest @ angular.js:12420Scope.$apply @ angular.js:12712(anonymous function) @ angular.js:18980x.event.dispatch @ jquery-2.0.3.min.js:5y.handle @ jquery-2.0.3.min.js:5
services.js:35 error: undefined
Also, when calling this:
var url = 'http://muser:mpasswd@myredmine/redmine/issues.json&callback=JSON_CALLBACK';
$http.jsonp(url).success(function (data) {
console.log('success');
}).error(function (error) {
console.log('error:: ' + error);
});
I get the same error
Please consider that muser, mpasswd and myredmine are just examples.