public static string UpdateRobotsWithNewMachineName(string token, Robots robot, string newMachineName, long newMachineId)

        {
            try
            {
                var modifiedRobot = new ModifiedRobot
                {
                    MachineId   = newMachineId,
                    MachineName = newMachineName
                };

                var jsonString = JsonConvert.SerializeObject(modifiedRobot);

                HttpContent httpContent = new StringContent(jsonString, Encoding.UTF8, "application/json");
                HttpClient  httpClient  = new HttpClient();
                httpClient.DefaultRequestHeaders.Remove("Authorization");
                httpClient.DefaultRequestHeaders.Add("Authorization", "Bearer " + token);

                string newPatchurl = String.Concat(ApiDetails.PatchRobotDetailsUrl(), "(", robot.Id.ToString(), ")");

                Uri newPatchUri = new Uri(newPatchurl);

                var responseMessage = httpClient.PatchAsync(newPatchUri, httpContent).Result;

                return(responseMessage.ToString());
            }
            catch (Exception ex)
            {
                Console.WriteLine("Exception : " + ex.Message);
                Console.WriteLine("Stack Trace : " + ex.StackTrace);

                throw;
            }
        }
        public static string PostAuthenticateToUiPathPlatform(string tenantName, string emailID, string password)
        {
            Console.WriteLine("Checking your credentials with Orchestrator ...");
            using (var wb = new WebClient())
            {
                var data = new NameValueCollection
                {
                    ["tenancyName"]            = tenantName,
                    ["usernameOrEmailAddress"] = emailID,
                    ["password"] = password
                };

                var    response         = wb.UploadValues(ApiDetails.GetAuthenticationUrl(), "POST", data);
                string responseInString = Encoding.UTF8.GetString(response);

                return(responseInString);
            }
        }
        public async static Task <string> GetRobots(string token)
        {
            try
            {
                HttpClient httpClient = new HttpClient();
                httpClient.DefaultRequestHeaders.Remove("Authorization");
                httpClient.DefaultRequestHeaders.Add("Authorization", "Bearer " + token);

                var response = await httpClient.GetStringAsync(ApiDetails.GetRobotsUrl());

                return(response.ToString());
            }
            catch (Exception ex)
            {
                Console.WriteLine("Exception : " + ex.Message);
                Console.WriteLine("Stack Trace : " + ex.StackTrace);

                return(null);
            }
        }
        public async static Task <string> GetMachines(string token)
        {
            try
            {
                Console.WriteLine("\n Getting Existing Machine details from Orchestrator .....");
                HttpClient httpClient = new HttpClient();
                httpClient.DefaultRequestHeaders.Remove("Authorization");
                httpClient.DefaultRequestHeaders.Add("Authorization", "Bearer " + token);

                var response = await httpClient.GetStringAsync(ApiDetails.GetMachinesUrl());

                return(response.ToString());
            }
            catch (Exception ex)
            {
                Console.WriteLine("Exception : " + ex.Message);
                Console.WriteLine("Stack Trace : " + ex.StackTrace);

                throw;
            }
        }