Beispiel #1
0
        public async Task <string> Run()
        {
            var API_KEY         = "[insert your api key here]";
            var SOLCAST_API_URL = "https://api.solcast.com.au/rooftop_sites";

            var site   = new RooftopSite("My Site", -149.117, 35.2);
            var client = new CreateRooftopSiteClient(API_KEY, SOLCAST_API_URL);

            var response = await client.PostAsync(site);

            response.EnsureSuccessStatusCode();

            return(await response.Content.ReadAsStringAsync());
        }
Beispiel #2
0
        public async Task <HttpResponseMessage> PostAsync(RooftopSite site)
        {
            if (site == null)
            {
                throw new ArgumentNullException(nameof(site));
            }

            using (var client = new HttpClient())
            {
                var json    = JsonConvert.SerializeObject(site);
                var content = new StringContent(json, Encoding.UTF8, "application/json");

                return(await client.PostAsync($"{Url}?format=json&api_key={ApiKey}", content));
            }
        }