I want to make a rest call to get web properties (i.e. /_api/web), for a different web application than the current. I have added the response headers
Access-Control-Allow-Credentials : true
Access-Control-Allow-Origin : *
Access-Control-Request-Method : GET,POST,HEAD,OPTIONS
in IIS.
Then I tried to make a ajax call
$.support.cors = true;
$.ajax({
url: "http://othersite/_api/web",
type: "GET",
//timeout: 8000,
//contentType: "application/json;odata=nometadata",
//cache: false,
crossDomain:true,
headers: {
"Accept": "application/json;odata=verbose"
},
xhrFields: { withCredentials: true },
success: function(data) {
console.log('worked');
},
error: function(jqXHR, textStatus, errorThrown) {
console.log('error');
}
});
but it doesn't work. I get 401 unauthorized. Does anyone know what is wrong?
Thanks
I even tried this
http://www.thesharepointguide.com/create-a-list-item-in-another-site-collection/
but same problem.
mysite
and the other ismysite:9000
. I believe this is considered different domain.