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
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.
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,240 Super User 2024 Season 2
Martin Dráb 230,149 Most Valuable Professional
nmaenpaa 101,156