Can we call an external REST API from custom widget ?
Try this it might help in resolving the issue.
windows icon -> Right click -> command prompt(Admin)
In command prompt window the type
C:\Windows\system32>cd .\drivers\etc and enter
C:\Windows\system32\drivers\etc>notepad hosts
A notepad of Hosts opens. Add the dns entry in the file like
10.11.11.11 maps.org.com
Thanks @KafilBaig
I did this but I keep getting CORS error which says that
Do I need to set something in WAB or AGOL to remove this error?
Yes, we can call an external REST API from custom widget. I have done in my custom widget.
For Example the code looks like as below.
FetchData: function () {
var apiUrl = "https://myservername/myApiname/MyMethodName";
var resultDataItems;
$.ajax({
async: false,
type: "GET",
url: apiUrl,
data: {"strParams": strParams},
success: function (result){
resultDataItems = JSON.parse(result);
}
});
Now you can bind the result in whatever display component you need in your application , for example Gridview, ListView...
Additionally Add the jquery.min library in your libs folder and reference that in index page.
Signed in members can post, follow updates, and more. New here? Register a free account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.