ASP.NET Core
A set of technologies in the .NET Framework for building web applications and XML web services.
4,553 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
The below code is failing with "the server responded with a status of 500 ()"
But data is being populated in elevation, I am trying to populate the elevation in browser using ajax call
but couldn't succeed.
https://api.open-meteo.com/v1/elevation?latitude=52.52&longitude=13.41
https://open-meteo.com/en/docs/elevation-api
string urlel = $"https://api.open-meteo.com/v1/elevation?latitude={data.latitude}&longitude={data.longitude}";
var responseel = client.GetAsync(urlel).Result;
string jsonel = await responseel.Content.ReadAsStringAsync();
dynamic datael = Newtonsoft.Json.JsonConvert.DeserializeObject(jsonel);
int elevation = datael.elevation;
your sample url returns
{
"elevation": [
38.0
]
}
so elevation is an array of numbers, not an int. try:
double elevation = datael.elevation[0];