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

Notifications

Announcements

No record found.

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans