Developed in an asp.net mvc I intend to implement an HTTP request
that with this part of the code the meteorologies present me a "list" with the metrics of the query data_de_leitura=2016-11-11&hora_de_leitura={null}
ie 3 meteorologies for the query that is added to the url
example:
api/Metereologias?data_de_leitura=2016-11-11&hora_de_leitura={null}
The result obtained regardless of the date and time value is always the same, all the weather of the api url.
var client = WebApiHttpClient.GetClient();
string path = "api/Metereologias?data_de_leitura=" + data + "hora_de_leitura=" + hora;
HttpResponseMessage response = await client.GetAsync(path);
if (response.IsSuccessStatusCode)
{
string content = await response.Content.ReadAsStringAsync();
var metereologias =
JsonConvert.DeserializeObject<IEnumerable<MetereologiaDTO>>(content);
await GetPois();
return View(metereologias);
On the api side, you have a method in the controller to handle this data
public List<MetereologiaDTO> GetMetereologiasSearchDataeHora(string data_de_leitura, string hora_de_leitura)
{
List<MetereologiaDTO> result = new List<MetereologiaDTO>();
result = verificarData(result, data_de_leitura);
result = verificarHora(result, hora_de_leitura);
return result;
}