I have a service that calls this service:
public async Task<List<Funcionario>> GetFuncionarios()
{
string url = $"http://localhost:56137/api/GetFuncionario";
var response = await client.GetStringAsync(url);
var _funcionario = JsonConvert.DeserializeObject<List<Funcionario>>(response);
return _funcionario;
}
How do I stop the url in the code, how are you?
That way it gives me error (I tried to do as colleague JJoão passed me)
var webConfig = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration(null);
string parametro = "GetCidade/{id}";
//if (webConfig.AppSettings.Settings.Count > 0)
//{
var customSetting = webConfig.AppSettings.Settings["serviceApi"];
string url = customSetting?.Value;
var response = await client.GetStringAsync(url + parametro);
var _cidade = JsonConvert.DeserializeObject<List<Cidade>>(response);
return _cidade;
I get this
An invalid request URI was provided. The request URI must either be an absolute URI or BaseAddress must be set.