Small update

master
Jan Beníček 2023-12-16 12:02:49 +01:00
parent 77441ec126
commit b1cd13a557
2 changed files with 12 additions and 12 deletions

View File

@ -22,15 +22,15 @@ namespace Wrapper_Api_SequentMicrosystems.Main
/// <exception cref="Exception">Error message</exception>
public async Task<Type?> GetData<Type>(string Endpoint)
{
HttpResponseMessage response = await _httpClient.GetAsync(Endpoint);
string response = await _httpClient.GetStringAsync(Endpoint);
if (response.IsSuccessStatusCode)
try
{
return JsonConvert.DeserializeObject<Type>(await response.Content.ReadAsStringAsync());
return JsonConvert.DeserializeObject<Type>(response);//await response.Content.ReadAsStringAsync());
}
else
catch (Exception ex) { }
{
throw new Exception(response.EnsureSuccessStatusCode().Content.ToString());
throw new Exception("GetData deserialize error");
}
}

View File

@ -31,14 +31,14 @@ namespace Wrapper_Api_SequentMicrosystems.RTD8TM
/// <returns>Deserialized data from API</returns>
public async Task<SortedList<byte, float[]>> Get(string address)
{
try
{
//try
//{
return await _client.GetData<SortedList<byte, float[]>>($"{address}api/RTDDA");
}
catch //(Exception ex)
{
return new();
}
//}
//catch (Exception ex)
//{
// throw new Exception(ex.Message);
//}
}
/// <summary>