patbef-ServiceInside/Support/Controllers/Https.cs

46 lines
1.4 KiB
C#
Raw Permalink Normal View History

2024-01-29 16:26:54 +01:00
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;
namespace Support.Controllers
{
public static class Https
{
public static Models.Version GetVersion(string _url)
{
Models.Version result = null;
try
{
if(!string.IsNullOrEmpty(_url))
{
string url = _url.Replace("/exchange/key", "") + "/exchange/key";
using (WebClient client = new WebClient())
{
ServicePointManager.ServerCertificateValidationCallback = (a, b, c, d) => true;
var reqparm = new System.Collections.Specialized.NameValueCollection();
byte[] responsebytes = client.UploadValues(url, "POST", reqparm);
string response = Encoding.UTF8.GetString(responsebytes);
if(!string.IsNullOrEmpty(response))
{
result = JsonConvert.DeserializeObject<Models.Version>(response);
}
}
}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
return result;
}
}
}