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 :
Microsoft Dynamics CRM (Archived)

Dynamics crm : Cross - origin Error using javascript call API

(0) ShareShare
ReportReport
Posted on by 5

Hello community ,

Actually I am trying to call an externel rest api that 's deployed in the same server as CRM ( with a different port ) using javascript 

CRM url : http://server:5555/organisation

Api url : http://server:9091/operation/id

here is my code 

{
var req = new XMLHttpRequest();
req.open("GET", url, true);
req.setRequestHeader("Accept", "application/json");
req.setRequestHeader("Content-Type", "application/json; charset=utf-8");
req.send();
req.onreadystatechange = function() {
if (this.readyState === 4) {
this.onreadystatechange = null;
if (this.status === 200) {
// do something ;
}  } }; }

But i get this following error  : 

Access to XMLHttpRequest at Api url from origin 'http://server:5555' 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.

Does any one had already faced this kind of issue ??Or have any workaround ? 

Please let me Know !!

Ps: I work on CRM 2015 on premise

*This post is locked for comments

I have the same question (0)
  • Verified answer
    gdas Profile Picture
    50,091 Moderator on at

    Hi ,

    Try to check below -

    - Add the external server name in the local host file .

    - Make sure you are allowing CORS  while sending request.

    - Add the URL in browser trusted sites.

    - Enable external data-source access.

     www.webdavsystem.com/.../cross_origin_requests

    You can also follow my answer here  -

    community.dynamics.com/.../281764

  • Suggested answer
    Shaminderpal Singh Profile Picture
    1,565 on at

    Hi,

    You need to specify crm url as accsess origin pass in your web api.

    Refer this-docs.microsoft.com/.../enabling-cross-origin-requests-in-web-api

    -Shaminder

  • Verified answer
    Jamil Lamyae Profile Picture
    5 on at

    Thanks a lot for your response I really appreciate it

    I activate the CROSS DOMAIN for IE from option tools and it works Fine for me 

  • Shaminderpal Singh Profile Picture
    1,565 on at

    That's not an ideal solution. CORS is used to prevent cross origin attacks and disabling it at browser level will make other applications vulnerable and prone to security attacks and also it will only work in IE and not other browsers.

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 > 🔒一 Microsoft Dynamics CRM (Archived)

#1
JS-09031509-0 Profile Picture

JS-09031509-0 3

#2
AS-17030037-0 Profile Picture

AS-17030037-0 2

#2
Mark Eckert Profile Picture

Mark Eckert 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans