I am using XMLHttpRequest() to connect with API and in console I have error about blocked by CORS policy. My url use https. How to connect with that API? I need some API-KEY or something like that?
I installed Allow-Control-Allow-Origin extension to chrome. It doesn't help
Example:
function UserAction() {
var xmlhttp = new XMLHttpRequest();
// xmlhttp.setRequestHeader('Accept', 'application/json');
xmlhttp.withCredentials = true;
xmlhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
var myObj = JSON.parse(this.responseText);
document.getElementById("demo").innerHTML = myObj.high;
}
};
xmlhttp.open("GET", "https://sinsmbe1.insepa.net:20106/m3api-rest/execute/CRS610MI/LstByNumber;maxrecs=100;returncols=CUNO,STAT?CUNO=10000", true);
xmlhttp.send();
}
I have 3 information from console.
Warning:
The connection used to load resources from https://sinsmbe1.insepa.net:20106 used TLS 1.0 or TLS 1.1, which are deprecated and will be disabled in the future. Once disabled, users will be prevented from loading these resources. The server should enable TLS 1.2 or later. See https://www.chromestatus.com/feature/5654791610957824 for more information.
Error:
Access to XMLHttpRequest at 'https://sinsmbe1.insepa.net:20106/m3api-rest/execute/CRS610MI/LstByNumber;maxrecs=100;returncols=CUNO,STAT?CUNO=10000' from origin 'null' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.
Warning:
Cross-Origin Read Blocking (CORB) blocked cross-origin response https://sinsmbe1.insepa.net:20106/m3api-rest/execute/CRS610MI/LstByNumber;maxrecs=100;returncols=CUNO,STAT?CUNO=10000 with MIME type application/vnd.sun.wadl+xml. See https://www.chromestatus.com/feature/5629709824032768 for more details.