How do I call my SOE using the JS API?

201
1
Jump to solution
07-09-2020 09:39 AM
chrisweaves
New Contributor II

Hi,

I have an SOE deployed and can call it fine using a browser using the following:

https://server/arcgis/rest/services/Testing/TestLayer/MapServer/exts/FeatureCountSOE/findNearbyFeatu...

That works fine and sends a json response with the feature count.

What I need is to replicate the call above but using the JS API, I have tried a few things but none seem to pass append the REST endpoint with the required parameters (layerId, location and distance), here's what I tried

var queryTask = new QueryTask({
    url:     "https://server/arcgis/rest/services/Testing/TestLayer/MapServer/exts/FeatureCountSOE/findNearbyFeatures",
    layerId: 0,
    distance: 10000,
    location: "{'x':0,'y':0,'spatialReference':{'wkid':3857}}",
    f: "json"
});

var query = new Query();
query.outFields = ["*"];
queryTask.execute(query).then(function(results){
    alert(results);
});

Am I way off the mark?  Feels like it :\

Thanks for your help!

0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Esteemed Contributor

Chris,

   Yes a query task is not the right class to use. You need to use esriRequest.

request | ArcGIS API for JavaScript 4.15 

Request data from a remote server | ArcGIS API for JavaScript 4.15 

View solution in original post

1 Reply
RobertScheitlin__GISP
MVP Esteemed Contributor

Chris,

   Yes a query task is not the right class to use. You need to use esriRequest.

request | ArcGIS API for JavaScript 4.15 

Request data from a remote server | ArcGIS API for JavaScript 4.15