Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Call external web service from web resource

(0) ShareShare
ReportReport
Posted on by

Hello,

I'm trying to call a method in a asp.net web api from a web resource using jquery ajax function (I've also tried with xmlhttprequest).

We're using onpremise crm 2016, and this external web api is located in the same server in which crm is installed.

I've tried the same call from another web application I created in the same iis with a different port, and it works fine. But when I deploy it to a web resource (I've even tried from the isv folder inside the crm web app) it fails.

When debugging with IE developer tools in the IE brower in the server, I've getting this message in the console:

XMLHttpRequest: Network Error 0x80070005, Access is denied.

How can I make this work? I've read some articles where other people can do it without doing special configurations and without having to make an action and pass parameters from js to call the external web api from the action.

Thank you.

*This post is locked for comments

  • Suggested answer
    Temmy Wahyu Raharjo Profile Picture
    2,914 on at
    RE: Call external web service from web resource

    Hi Vermin,

    Share your code so we can understand better about your situation. Usually I will try to invoke my API using postman before I do coding to make sure I'm not miss out the configuration to call my API. Below is the example to calling using jquery ajax.

    $.ajax({

                   url: url,

                   dataType: "jsonp",

                   async: true,

                   type: "GET",

                   timeout: 120000,

                   jsonpCallback: "MyCallback",

                   success: function (data, textStatus, jqXHR) {

                       //Success action

                   },

                   error: function (jqXHR, textStatus, errorThrown) {

                     //Error action

                   },

                   complete: function (jqXHR, textStatus) {

                       //Complete action

                   }

               });

  • Community Member Profile Picture
    on at
    RE: Call external web service from web resource

    Hello. Thank you for your answer.

    I knew I could use an action as a bridge to call the asp net web api from it, but I didn't want to do it because one of the functionalities my web resource has is to give the user the functionality to pick a file and upload it to the server from their computers (they don't want to use the built-in Notes). To use actions for this would take me to upload the file to a temporal note to be then taken by the action. Too much executing time, as there is more logic in the server done by the web api.

    I'm afraid that if there's no way to call directly from a js web resource to a external web api, I'll have to take out the full functionality to a external form and have it in an i-frame in CRM.

    One more thing. Is Process.js supported? It makes use of the javascript namespace MsCrm and from what I know, it's internal and it could change without warning from MS.

  • Suggested answer
    Preeti Sharma Profile Picture
    2,678 on at
    RE: Call external web service from web resource

    Hi,

    You can follow below steps to call external webapi through javascript:

    1. Create a custom activity  (c#) to call web api and deploy it to CRM

    2. Create Custom Action and add the activity (created and deployed in step 1) as a step

    3. Call this custom action in your javascript (You can use Process.js to call custom action easily)

    Below links may be helpful to you:

    Use Process.js:

    1. archive.codeplex.com

    2. stackoverflow.com/.../call-action-using-process-js-crm

    Hope this helps:)

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

Understanding Microsoft Agents - Introductory Session

Confused about how agents work across the Microsoft ecosystem? Register today!

Adis Hodzic – Community Spotlight

We are honored to recognize Adis Hodzic as our May 2025 Community…

Kudos to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard > Microsoft Dynamics CRM (Archived)

#1
Mohamed Amine Mahmoudi Profile Picture

Mohamed Amine Mahmoudi 83 Super User 2025 Season 1

#2
Community Member Profile Picture

Community Member 52

#3
dkrishna Profile Picture

dkrishna 6

Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans