angularjs - Cross-origin Ajax request to API returns 500 (Internal Server Error) response -


i getting error response '500 (internal server error)' when get call api. here’s error message:

xmlhttprequest cannot load http://10.10.14.188:4800/api/v1/healthmonitor/devicestatus. response preflight request doesn't pass access control check: no 'access-control-allow-origin' header present on requested resource. origin 'http://192.168.4.217' therefore not allowed access. response had http status code 500.

…though response when try postman or using curl command.

in call, have pass id in header. here code:

this.getstate = function () {         return $http({                 method: 'get',                 url: 'http://10.10.14.188:4800/api/v1/healthmonitor/devicestatus',                 headers: {'jab_device_id': '80f1374192a6d6eb9ebf48e2eba18366','content-type': 'application/json'}                 });     }; 

also, tried ajax got same error. here code:

$.ajax({         url: 'http://10.10.14.188:4800/api/v1/healthmonitor/devicestatus',         headers: {           'jab_device_id':'80f1374192a6d6eb9ebf48e2eba18366'           },         method: 'get',         withcredentials: true,         success: function(data){           console.log('succes: '+data);         }       }); 

var url = "http://10.10.14.188:4800/api/v1/healthmonitor/devicestatus"; $http({     method: 'jsonp',     url: url,     headers: {'jab_device_id': '80f1374192a6d6eb9ebf48e2eba18366','content-type': 'application/json'} }). success(function(status) {     //your code when success }). error(function(status) {     //your code when fails }); 

cors cross origin resource sharing, error if trying access 1 domain domain.

try using jsonp. in case, jsonp should work fine because uses method.

try this:

from this answer

but if have access rest api update filters enable cors request if cant perform other operation


Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -