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)

CROS Request fails from CRM Web Resource

(0) ShareShare
ReportReport
Posted on by 390

Hi,

I am facing issue in chrome while calling web api from crm html web resource using XMLHttpRequest. CRM 2016 and API deployed in the same server but different port numbers. So this is a cross domain request. I am able to get the response successfully from API using IE but not in chrome. Sadly our customer only use chrome. We have been struggling to find a solution for this for more than 1 month. Please suggest a solution for this.

Thanks.

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Joe Griffin Profile Picture
    1,254 on at

    Hi Jayakumar,

    In order to get around this issue in the past, I have rewrote my HTML Web Resources into an ASP.NET page. This page is then able to make external web API calls without encountering the cross domain issue, which can then be displayed within CRM as as an IFrame. If you have knowledge of ASP.NET/C# or VB.NET, then I would recommend going down this route.

    Hope this helps!

    Thanks

    Joe

  • Jayakumar Profile Picture
    390 on at

    Hi Joe,

    Thanks for reply. Our customer is bank. They don't want to use ASP,NET custom pages. We have to do it in HTML and Javascript only. I want to know is it possible? If not possible then we can tell the customer.

    Thanks.

  • Community Member Profile Picture
    on at

    As i know this is not possible in CRM on-premise, but do you really need to use javascript?  Maybe you can workaround this using custom action or workflow.

  • Suggested answer
    Alagunellaikumar Profile Picture
    6,212 on at

    Hi Jaykumar,

    The error is due to cross domain access. Simple fix host your WEB API inside your CRM website.

    Second fix, since it is web API(i hope u are using c#) add dll inside your project Install-Package Microsoft.AspNet.WebApi.Cors(nudget).

    It will change your webconfig by adding "allow-cors" in webconfig

  • Jayakumar Profile Picture
    390 on at

    Yes. I can achieve this using custom action but is there no way using JavaScript.

  • Jayakumar Profile Picture
    390 on at

    Hi Alagu,

    I have made changes in web api. But still does not work form chrome.

  • Suggested answer
    JohnAnonymous Profile Picture
    5,241 on at

    Can you post the error form Chome? Is it indication that it's an issue with CORS?

    If so, you need to enable CORS in your WebApi, assuming it's something you've developed yourself.

    This might help you on your way:

    www.asp.net/.../enabling-cross-origin-requests-in-web-api

    And another one:

    enable-cors.org/server_iis7.html

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