How do I call the REST API https://www.arcgis.com/sharing/generateToken?username=<>&password=<>&referer=https://geoenrich.arcgis.com&f=json from a javascript method? I tried using jquery ajax request and found it working sometime and sometime the request is always pending.
And for the the following url, I do not find any specific query that I need to use? In Arc GIS 3.19 version I saw esri.tasks.locationproviders.StandardGeographyQueryLocationProvider but in 4 it is not there. If I make normal ajax call using jquery it does not work at all.
Please help me to resolve the problem.
Also tried using ARC GIS 4.2 and Query API from there.
function(token){ require(["esri/request"], function(esriRequest) { var url = "http://geoenrich.arcgis.com/arcgis/rest/services/World/geoenrichmentserver/StandardGeographyQuery/execute?sourceCountry=US&geographylayers=[%22US.Counties%22]&geographyQuery=orange&f=pjson&token="+token+"&returnGeometry=true"; esriRequest(url, { responseType: "json", callbackParamName: "callback", }).then(function(response){ // The requested data alert(response); }); }); }
This also did not work for me.
$.ajax({ url: "http://geoenrich.arcgis.com/arcgis/rest/services/World/geoenrichmentserver/StandardGeographyQuery/execute?sourceCountry=US&geographylayers=[%22US.Counties%22]&geographyQuery=orange&f=pjson&token="+token+"&returnGeometry=true", dataType: 'jsonp', type: 'GET', crossDomain: true, contentType: "application/json; charset=utf-8;", async: false, // jsonpCallback:"callback", success: function(result){ if(result.error){ return false; }else{ return true; } }, error: function(result){ console.log(result); alert('error'); } });
Tried thsi with jquery it did not work for me.
Is it possible to provide some code to show what you are trying to do and where the problem is?
We are using 4.2 version. I am clueless which class do I need to use to call any of the REST APIS including GeoEnrich.
I tried using esri\request. But it did not work . I have to use jsonp.
Have a look at esri.request:
3.19: esri/request | API Reference | ArcGIS API for JavaScript 3.19
4.2: request | API Reference | ArcGIS API for JavaScript 4.2
サインインしたメンバーは投稿、更新のフォローなどができます。初めてですか?無料アカウントを登録してください。
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.