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

Community site session details

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

Cannot call external API in CRM in Javascript

(0) ShareShare
ReportReport
Posted on by 90

I am trying to call an API from Finance and Operations in CRM Dynamics 365 but i am getting error :

"Access to XMLHttpRequest at 'abc.dynamics.com/api/services/SalesOrderTest' from origin 'xyz.crm.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."

I tried to set these headers but still getting the error  

   xhr.setRequestHeader("Access-Control-Allow-Origin","*")
   xhr.setRequestHeader("Access-Control-Allow-Credentials""true");
   xhr.setRequestHeader("Access-Control-Allow-Methods""GET, POST, PUT, DELETE, OPTIONS");
   xhr.setRequestHeader("Access-Control-Allow-Headers""*");
 
I have the same question (0)
  • Suggested answer
    Bipin D365 Profile Picture
    28,983 Moderator on at
    RE: Cannot call external API in CRM in Javascript

    Hi,

    You have two options to fix your issue

    1. Enable CORS on target web application which is F&O

    2. Use custom action to execute your api call server side and call custom action from JS n CRM

    Please Mark My Answer Verified If I Were Helpful

  • CSafwat Profile Picture
    90 on at
    RE: Cannot call external API in CRM in Javascript

    Thanks Bipin for your reply.

    Could you please tell me how to enable CORS on F&O ?

  • Suggested answer
    Bipin D365 Profile Picture
    28,983 Moderator on at
    RE: Cannot call external API in CRM in Javascript

    Hi,

    Check below link which might be helpful.

    community.dynamics.com/.../enable-cors-on-dynamics-365-for-operations

    Please Mark My Answer Verified If I Were Helpful

  • CSafwat Profile Picture
    90 on at
    RE: Cannot call external API in CRM in Javascript

    Hi Bipin,

    This link isn't helpful and i can't find how to enable CORS on F&O.

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…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
Rishabh Kanaskar Profile Picture

Rishabh Kanaskar 149

#2
MVP-Daniyal Khaleel Profile Picture

MVP-Daniyal Khaleel 142

#3
Tom_Gioielli Profile Picture

Tom_Gioielli 125 Super User 2025 Season 2

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans