I am connection to a Map Service that requires a token and this code works to get the list of layers (where url is something like http://myhost/arcgis/rest/services/MapServer?token=abcdefg😞
using (var client = new HttpClient())
{
client.BaseAddress = new Uri(url + "&f=pjson");
client.DefaultRequestHeaders.Accept.Clear();
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
return client.GetAsync("").Result;
}
I then want to go through each layer and add it as a feature layer to a map (where layerUrl looks like http://myhost/arcgis/rest/services/MapServer/5?token=abcdefg)
Uri serviceUri = new Uri(layerUrl);
FeatureLayer layer = new FeatureLayer(serviceUri);
await layer.LoadAsync();
Map.OperationalLayers.Add(layer);
This does not seem to be working. I am getting no errors, but the layer is also showing no features. Is it obvious what I am doing wrong?