Azure
A cloud computing platform and infrastructure for building, deploying and managing applications and services through a worldwide network of Microsoft-managed datacenters.
1,026 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
I am working on a desktop app and I have been able to bring the map in the WPF window using Azure Maps. I am trying to get the elevation of a given point. I used the API call given in this article: https://techcommunity.microsoft.com/t5/azure-maps/preview-of-new-azure-maps-elevation-service-rest-apis/m-p/1957321/highlight/false#M47
But I am getting the error below when I debug the "HttpResponseMessage response" in my code.
response = {StatusCode: 404, ReasonPhrase: 'Not Found', Version: 1.1,.....
my method goes like below (with the subscription key hidden)
private static string GetElevationFromCoordinates(double latitude, double longitude)
{
string subscriptionKey = "myHiddenSubscriptionKey";
string baseUrl = "https://atlas.microsoft.com/elevation/point/json";
string url = $"{baseUrl}?api-version=1.0&subscription-key={subscriptionKey}&query={latitude},{longitude}";
using (HttpClient client = new HttpClient())
{
HttpResponseMessage response = client.GetAsync(url).Result;
response.EnsureSuccessStatusCode();
string responseBody = response.Content.ReadAsStringAsync().Result;
JObject json = JObject.Parse(responseBody);
double elevation = json["data"]["elevationInMeters"].Value<double>();
return $"Elevation: {elevation} meters";
}
}