1
How I pass the object login
as a parameter for the method GetAsync
?
I’m trying to do it this way, but I didn’t get the error message:
private async Task<JsonResult> obterLogin(Login login)
{
try
{
HttpClient httpCliente = new HttpClient();
httpCliente.BaseAddress = new Uri("http://localhost:55838/");
httpCliente.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
HttpResponseMessage response = await httpCliente.GetAsync("MedClinApi/Login/Obter/ { login }", login);
var json = await response.Content.ReadAsStringAsync();
return JsonConvert.DeserializeObject<JsonResult>(json, new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() });
}
catch
{
throw;
}
}
The message is quite explicit. The method Getasync expects a parameter of type Httpcompletionoption and an object like Login. The method Getasync does not have signatures allowing to pass objects: https://msdn.microsoft.com/en-us/library/system.net.http.httpclient.getasync(v=vs.118). aspx
– João Martins