web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Suggested Answer

MS CRM Web API blocked by CORS policy

(0) ShareShare
ReportReport
Posted on by

Hi Experts,

I am facing API blocked by CORS policy error when i trying to access data from my custom WEP API.

below code i am using for call wep API call.

var orgurl = "<web api url>";
var req = new XMLHttpRequest();
req.open("GET", encodeURI(orgurl), false);
req.setRequestHeader("OData-MaxVersion", "4.0");
req.setRequestHeader("OData-Version", "4.0");
req.setRequestHeader("Accept", "application/json");
req.setRequestHeader("Content-Type", "application/json; charset=utf-8");
req.setRequestHeader("Prefer", "odata.include-annotations=\"*\"");
req.setRequestHeader('Access-Control-Allow-Credentials', 'false');
req.setRequestHeader('Access-Control-Allow-Origin', '*');
req.setRequestHeader('Access-Control-Allow-Methods', '*');
req.setRequestHeader('Access-Control-Allow-Headers', "*");
req.onreadystatechange = function () {
if (this.readyState === 4) {
req.onreadystatechange = null;
console.log("this.status: " + this.status);
if (this.status === 200) {
console.log("this.response: " + this.response);
var result = JSON.parse(this.response);
if (result.length > 0) {
for (var i = 0; i < result.length; i++) {
var obj = {};
obj.name = result[i].NAME;
console.log("obj: "+obj);
}
}
}
} else {
alert(this.statusText);
}
}
};
req.send();

below is error message:

Access to XMLHttpRequest at '<Web Api Url>' from origin 'https://<Org>.dynamics.com' 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.

Above code is working fine if i am using chrome after disable-web-security.

using command  "chrome.exe --user-data-dir="C:/Chrome dev session" --disable-web-security"

i have added CROS Origin allow settings in Web API C# config and controller files as well, still i am unable to get response from my Web API.

Please provide your suggestions. 

I have the same question (0)
  • priyatham Profile Picture
    15 on at

    Hi,

    Do you still have this issue?

  • Suggested answer
    bravoreddy Profile Picture
    67 on at

    When I had this issue and we realized this the vpn addresses has to be whitelisted for this api url for your CRM server.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
ManoVerse Profile Picture

ManoVerse 181 Super User 2026 Season 1

#2
11manish Profile Picture

11manish 139

#3
CU11031447-0 Profile Picture

CU11031447-0 100

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans