using System; using System.Text; using System.Net.Http; using Newtonsoft.Json; namespace SolarData { class Program { static void Main(string[] args) { string url = "https://vrmapi.victronenergy.com/v2/"; string username = "your vrm user name"; string password = "your vrm password"; try { HttpClient httpClient = new HttpClient(); Uri baseAddress = new Uri(url); httpClient.BaseAddress = baseAddress; System.Net.ServicePointManager.ServerCertificateValidationCallback = delegate { return true; }; System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls12; string user = @"{ ""username"":""" + username + @""","; string pass = @" ""password"":""" + password+ @"""}"; HttpContent content = new StringContent(user+pass,Encoding.UTF8, "application/json"); HttpResponseMessage rm = httpClient.PostAsync("auth/login/", content).Result; string responseData = rm.Content.ReadAsStringAsync().Result; dynamic resp = JsonConvert.DeserializeObject(responseData); string id = resp["idUser"]; string token = resp["token"]; httpClient.DefaultRequestHeaders.TryAddWithoutValidation("X-Authorization", "Bearer " + token); try { HttpResponseMessage response = httpClient.GetAsync("users/"+id+"/installations").Result; responseData = response.Content.ReadAsStringAsync().Result; resp = JsonConvert.DeserializeObject(responseData); } catch (Exception ex) { Console.WriteLine(ex.Message); } } catch (Exception ex) { Console.WriteLine(ex.Message); } } } }