Get Company Last Reading Date


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 GetCompanyLastReadingDate(string token)
            {
                HttpClient apiClient = new HttpClient();
                string route = "/api/company";

                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 + "/getlastreadingdate", strContent).Result;

                Console.WriteLine(response.StatusCode);

                if (response.StatusCode == System.Net.HttpStatusCode.OK)
                {
                    Console.WriteLine("-------------------");
                    Console.WriteLine(response.Content.ReadAsStringAsync().Result);
                }
                else
                    Console.WriteLine($"{response.Content.ReadAsStringAsync().Result} - Not authorized");
            }
        
    

C# Flurl

    
            static void FlurlGetCompanyLastReadingDate(string token)
            {
                var response = _host.AppendPathSegment("/api/company/getlastreadingdate").WithOAuthBearerToken(token).PostJsonAsync(LogMeIn()).Result;

                if (response.StatusCode == System.Net.HttpStatusCode.OK)
                {
                    Console.WriteLine("-------------------");
                    Console.WriteLine(response.Content.ReadAsStringAsync().Result);
                }
                else
                    Console.WriteLine($"{response.Content.ReadAsStringAsync().Result} - Not authorized");
            }