Turn OFF specified HUB


Static Host Value

      
            static string _host = "https://astuteincservices.com";
        
    

A method named LogMeIn() returns an instance of DGLogInRequest with your credentials.


C# HTTP

        
            static void TurnOffHub(string token)
            {
                HttpClient apiClient = new HttpClient();
                string route = "/api/hub";

                var json = JsonConvert.SerializeObject(LogMeIn());
                var strContent = new StringContent(json, UnicodeEncoding.UTF8, "application/json");
                apiClient.DefaultRequestHeaders.Clear();
                apiClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);

                var response = apiClient.PostAsync(_host + route + "/TurnOff/352753091969608", strContent).Result;

                Console.WriteLine(response.StatusCode);

                if (response.StatusCode == System.Net.HttpStatusCode.OK)
                {
                    if (string.IsNullOrEmpty(response.Content.ReadAsStringAsync().Result))
                        Console.WriteLine("Hub Turned Off");
                    else
                        Console.WriteLine(response.Content.ReadAsStringAsync().Result);
                    }
                    else
                    {
                        Console.WriteLine("-------------------");
                        Console.WriteLine(response.Content.ReadAsStringAsync().Result);
                }
            }
        
    

C# Flurl

    
            static void FlurlTurnOffHub(string token)
            {
                var response = _host.AppendPathSegment("/api/hub/TurnOff/352753091969608").WithOAuthBearerToken(token).PostJsonAsync(LogMeIn()).Result;

                if (response.StatusCode == System.Net.HttpStatusCode.OK)
                {
                    if (string.IsNullOrEmpty(response.Content.ReadAsStringAsync().Result))
                        Console.WriteLine("Hub Turned Off");
                    else
                        Console.WriteLine(response.Content.ReadAsStringAsync().Result);
                }
            }