I have a website on SharePoint Online and a website on SharePoint On-premise. From my On-premise website i want to create a new list on my SharePoint Online site.
To authenticate I used the following codes:
var soapRequest =
'<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
<soap12:Body>
<Login xmlns="http://schemas.microsoft.com/sharepoint/soap/">
<username>[email protected]</username>
<password>userpassword</password>
</Login>
</soap12:Body>
</soap12:Envelope>';
And then:
$.ajax({
url: myUrl + "_vti_bin/authentication.asmx?op=Login",
type: "GET",
contentType: "text/xml",
dataType: "json",
data: soapRequest,
success: function (a) {
console.log(a);
},
error: function (a) {
console.log(a);
}
});
As result I get:
XMLHttpRequest cannot load https://myUrl/_vti_bin/authenti…in3!%22%3C/password%3E%3C/Login%3E%3C/soap12:Body%3E%3C/soap12:Envelope%3E. The request was redirected to 'https://myUrl/_layouts/15/error.aspx?ErrorText=Request%20format%20is%20unrecognized%2E', which is disallowed for cross-origin requests that require preflight.
What can I do to avoid the error?
Thank you very much.