Hi, I’m a web developer working on a weather app. When I use my provided APP ID and API key, I get an XML object. I would like, instead, to get a JSON object. How is this possible? Thanks in advance for your help! Please send any emails to gebremesquitta@gmail.com.
This is the Vb.Net code I use to get a JSON object:
Dim url = $“http://api.weatherunlocked.com/api/forecast/us.{Zipcode}?app_id={AppId}&app_key={AppKey}”
Dim client = New HttpClient()
With client.DefaultRequestHeaders
.UserAgent.ParseAdd(USE_AGENT)
.AcceptEncoding.Add(New StringWithQualityHeaderValue(“gzip”))
.Accept.Add(New MediaTypeWithQualityHeaderValue(“application/json”))
End With
client.DefaultRequestHeaders.UserAgent.ParseAdd(USE_AGENT)
Dim rb = Await client.GetStringAsync(New Uri(url))
to get a json object, I wrote in vanilla javascript:
getWeather()
.then(response => {
console.log(“success!”);
})
.catch(error => {
console.log(error);
console.error(error);
});
async function getWeather() {
const response = await fetch(url);
const results = await response.json();
console.log(results);
doSomething(results);
}
all this happens inside a function on submit, which creates my url. Url looks like:
let url = “https://api.weatherunlocked.com/api/resortforecast/” + resortID + “?num_of_days=3&app_id=” + appID + “&app_key=” + apiKey;