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 :
Customer experience | Sales, Customer Insights,...
Suggested Answer

How to call a Asynchronous API with Azure URL and subscription key through JavaScript

(0) ShareShare
ReportReport
Posted on by 135

Hello Folks,

I have a query. I’m calling Async Api using a javascript on click of a button. I’m using Azure API URL and subscription key to trigger the same. When i use this from postman using Get method it works but when i try from the JS i don’t get any output nor error. It hit the url but no response. When checked in the splunk logs i get Method as options and not GET and i get 500 error whereas through postman i can update the field in CRM Without any issue. Below is the code. Could anyone suggest a solution please.

function submitStatus(selectedIds) {

    debugger;

    if (selectedIds != null && selectedIds != "") {

        var xRequestID = generateUUID();

        var orderRequest = new XMLHttpRequest();

Xrm.WebApi.retrieveRecord("profile", selectedIds, "?$select=name").then(

                                function success(result) {

 var name=result.name;      

 var url = "https://azureapiurl/“+name ;                                       orderRequest.open("GET", url, true);

 orderRequest.setRequestHeader("api-key", subscriptionKey);

orderRequest.setRequestHeader("Content-Type", "application/json");

 orderRequest.setRequestHeader("X-Request-ID", xRequestID);

 orderRequest.send(null);

  },

 function (error) {}

                );

          }

}

Regards,

Hima 

I have the same question (0)
  • Suggested answer
    sdfasdf Profile Picture
    842 on at

    Hello,

    What is the error message precisely? It might be the case that you're running into CORS issue, which takes place when a JS code hosted in one domain tries to communicate with a service hosted under a different domain. If that is the case, you might want to consider using JSONP to work around that.

    Hope it 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

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 > Customer experience | Sales, Customer Insights, CRM

#1
Pallavi Phade Profile Picture

Pallavi Phade 98

#2
Tom_Gioielli Profile Picture

Tom_Gioielli 46 Super User 2025 Season 2

#3
Gerardo Rentería García Profile Picture

Gerardo Rentería Ga... 43 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans