hi Guys, i have one javascript i need to call external webapi with one parameter how to call the webapi using javascript and capture the return value to the javascript in dynamcis crm.
Thank You
hi Guys, i have one javascript i need to call external webapi with one parameter how to call the webapi using javascript and capture the return value to the javascript in dynamcis crm.
Thank You
Hi ,
Please find the sample code for the POST Request,
Note: Only HTTPS requests are allowed from D365.
var data = JSON.stringify({
"name": "morpheus",
"job": "leader"
});
var url = "https://reqres.in/api/users";
var xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener("readystatechange", function () {
if (this.readyState === 4) {
console.log(this.responseText);
}
});
xhr.open("POST", url);
xhr.setRequestHeader("Content-Type", "application/json");
xhr.send(data);
You can also learn how to make HTTPS call using JS or Ajax request.
Hi Dinesh,
It depend on what kind of the request method the API uses, and whether you need a authentication to call it.
Here is a simple demo to call NASA(https://api.nasa.gov/#getting-started) public API, it can be easily done with jQuery ajax method.
(This API is to get an article information, and I only get its title field from callback result)
1. Add jQuery and your own js libraries in CRM form.
2. Add your ajax call function in js by yourself.
3. In my demo, I call the function when form load
result:
There are some previous discusses about your question, you could take them as reference:
https://community.dynamics.com/crm/f/117/t/270302
https://community.dynamics.com/crm/f/117/t/276186
Regards,
Clofly
You could use the fetch api (not supported by IE without a polyfil though) developer.mozilla.org/.../Fetch_API
Or JQuery... api.jquery.com/.../ajax
Or one of the many other libraries out there.
What is the external webapi? Does it not provide documentation?
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... 290,277 Super User 2024 Season 2
Martin Dráb 228,126 Most Valuable Professional
nmaenpaa 101,148