Notifications
Announcements
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
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?
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
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.
https://www.freecodecamp.org/news/here-is-the-most-popular-ways-to-make-an-http-request-in-javascript-954ce8c95aaa/
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.
Congratulations to a top community star!
In our never-ending quest to help the Dynamics 365 Community members get answers faster …
Welcome to the next edition of the Community Platform Update. This is a status …
Stay up to date on forum activity by subscribing.