hsidhu Posted November 14, 2015 Report Share Posted November 14, 2015 Hello Everyone, I am trying to make javascript ajax call to rest api of voida api e.g /rest/session but getting cors error. I tried different solutions but didn't worked. I am using following code. var vars = { "name": "auth", "value": "admin " + CryptoJS.MD5('password') }; $.ajax({ type: "PUT", url: 'http://[pbx]/rest/system/session', headers:{ "Access-Control-Allow-Origin": "*", 'Access-Control-Allow-Headers': 'Content-Type, X-Requested-With, Origin, Accept', 'Access-Control-Allow-Methods': 'HEAD, GET, POST, PUT, DELETE, OPTIONS', }, dataType: 'json', async: true, data: JSON.stringify(vars), success: function(data){ console.log(data); }, error: function(data){ console.log(data); } }); I am getting following errors OPTIONS http://[pbx]/rest/system/session send @ jquery.js:8630jQuery.extend.ajax @ jquery.js:8166loadView @ status.js:396(anonymous function) XMLHttpRequest cannot load http://[pbx]/rest/system/session. Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://[HOST]' is therefore not allowed access. The response had HTTP status code 403. IF you guys can look into it will solve another problems for me. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.