There's a new home for Articles. Find Articles on Our Product Support Page.
Hello SOTI team, I am developing an app with SOTI-SNAP wherein I use javascript to use a AspNetCore REST service from our server located on the internet.When developing I use the preview function of SOTI-Snap in the browser (Chrome). Calls with the GET method works from preview. But the POST method returns the following error in the browser console: Access to XMLHttpRequest at 'https://[OurServer].com/soticlean/TimeRecords' from origin 'https://s3.eu-central-1.amazonaws.com' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: It does not have HTTP ok status. Here my Javascript call from my app: var settings = { "url": Snap.variables.getValue("gvarServiceURL"), "method": "POST", "timeout": 0, "headers": { "Content-Type": "application/json" }, "data": JSON.stringify( { "deviceUid": data.deviceUid, "date": data.date }), }; return $.ajax(settings).done(function (response) { console.log(JSON.stringify(response)); alert(JSON.stringify(response)); }).fail(function (response) { alert(JSON.stringify(response)); }); } And here the customHeader section from my Web.config of my AspNetCore REST Service: ... <system.webServer> <httpProtocol> <customHeaders> <add name="Access-Control-Allow-Origin" value="https://s3.eu-central-1.amazonaws.com" /> <add name="Access-Control-Allow-Headers" value="Content-Type"/> <add name="Access-Control-Allow-Methods" value="GET,PUT,POST,DELETE,OPTIONS" /> </customHeaders> </httpProtocol> .... I hope someone can help me. Thanks a lot Martin
Top-tier experts who are delivering outstanding content. Should have more than 7000 points.
Experts who are consistent with great content. Should have more than 1000 points
Highly experienced members with valuable inputs. Should have more than 700 points
Beginners taking the initiative. Should have more than 500 points