I have run in to a problem. Please help with your expertise.
I am developing web solution for a company. They have provided me Web API Method (REST). This API is in their domain. I am too access this from my domain. Even client has also already whitelisted my domain.
I am trying to call this method using below. But no luck. I am getting this below error.
Error NS_ERROR_DOM_BAD_URI: Access to restricted URI denied
function GetCustomerInfo() { var Url = "http://webapi.company.com/vx.x/customer/get?format=xml&mobile=9876543210" ; myXmlHttp = new XMLHttpRequest(); myXmlHttp.withCredentials = true; myXmlHttp.onreadystatechange = ProcessRequest; myXmlHttp.open( "GET", Url, true,"UID","PWD"); myXmlHttp.send(); }
function ProcessRequest() {
if(this.readyState == this.DONE)
{
if(this.status == 200 && this.responseXML != null )
{
alert ("Received Resoponse from Server");
}
else
{
alert ("Some Problem");
}
}
}
I am able to access this method from RESTClient in firefox plugin. Even I am able to access this method copying credentials in URL as below in browser address bar. I get anticipated response XML
http://UID:PWD@webapi.company.com/vx.x/customer/get?format=xml&mobile=9876543210
Please enlighten me where I am wrong. Perhaps JSONP can come to my help. But why i am not able to access this API using XMLHttpRequest.
Regards Rajul