//Load course and user private async void btnLoadCourse_Click(object sender, EventArgs e) { try { //Ensure active token if (Properties.Settings.Default.CurrentAccessToken != "No Access Token" && Properties.Settings.Default.CurrentAccessToken != "") { if (nudCourseID.Value == 1) { MessageBox.Show("Please Enter a Course ID"); } else { if (txbPageName.TextLength > 0 & nudCourseID.Value > 1) { buttonSubmitPage.Enabled = true; } else { buttonSubmitPage.Enabled = false; } //allow user to input course name txbBaseName.Enabled = true; //Setting wait curser Cursor.Current = Cursors.WaitCursor; //Make Call to get user name if (Properties.Settings.Default.CurrentAccessToken != "No Access Token" && Properties.Settings.Default.CurrentAccessToken != "") { string profileObject = "name"; string userName = await getProfile.GetProfile(profileObject); //Print message labelLoggedIn.Text = "Logged in as " + userName; } else { labelLoggedIn.Text = "Not logged in"; } //Get course name try { //Get Course Name String endPoint = Properties.Settings.Default.InstructureSite + "/api/v1/courses/" + nudCourseID.Value + "?"; Requester requester = new Requester(); var json = await requester.MakeRequestAsync(endPoint); //deserialize the JSON object dynamic jsonObj = JsonConvert.DeserializeObject(json); //parse the JSON object dynamic data = JObject.Parse(json); //Printing out results rtbResults.AppendText("Course " + Convert.ToString(data.name) + " has been selected!\n"); } catch (Exception courseIDChangeException) { rtbResults.AppendText(courseIDChangeException.Message + "\n"); } //End Wait Cursor Cursor.Current = Cursors.Default; } }//end login if else { MessageBox.Show("Not logged in. Enter valid token", "Authentication error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }//end try catch (Exception apiException) { MessageBox.Show("Token not authorized. Input valid token.\n" + apiException.Message, "Authentication error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }// end load course
private async void buttonSubmitPage_Click(object sender, EventArgs e) { string restResult = "No Call Made"; //this will be over written by results from web call string endPoint = Properties.Settings.Default.InstructureSite + "/api/v1/courses/" + Convert.ToString(nudCourseID.Value) + "/pages?"; //Get base endpoint from setting Requester requester = new Requester(); int pageToMake = Convert.ToInt32(nudNumberOfAssign.Value); int pageNumber = 0; //Setting parameters currentPage.editing_roles = currentPage.EditRoles(radioButtonTeachers.Checked, radioButtonTeachandStu.Checked, radioButtonAnyone.Checked); currentPage.notify_of_update = checkBoxContentChange.Checked; currentPage.published = checkBoxPagePublish.Checked; //combining all parameters //Make API Call try { //Validate fields //Write out submit header rtbResults.AppendText(String.Format("{0,-50} {1,-10}\n", "Page Name", "Status")); //Write Repeating submit if (xbxUseBase.Checked == true) { try { //Validate Number in text var pattern = @"\[([^\]]*)\]"; var inputNumber = Regex.Match(txbBaseName.Text, pattern).Value.Replace("[", "").Replace("]", ""); pageNumber = Convert.ToInt32(inputNumber); //While loop to run until Quizes to make is zero try { for (int i = 1; i <= pageToMake; i++) { //Incrementing page number currentPage.title = Regex.Replace(txbBaseName.Text, @"\[([^\]]*)\]", Convert.ToString(pageNumber)); currentPage.body = Regex.Replace(rtbPageBody.Text, @"\[([^\]]*)\]", currentPage.title); //REST Call var jsonString = $"{{\"wiki_page\":{JsonConvert.SerializeObject(currentPage)}}}"; restResult = await requester.MakePOSTRequestAsync(endPoint, jsonString); //Write Results to Text box rtbResults.AppendText(String.Format("{0,-50} {1,-10}\n", currentPage.title, "Created")); pageNumber++; }//End Repeating submit while statement //Clear Page names txbBaseName.Text = ""; txbPageName.Text = ""; }//End try catch (Exception apiException) { MessageBox.Show(apiException.Message); } }//End try On validating text in bracket catch (FormatException bracketNumberException) { MessageBox.Show("Please enter a number in brackets or uncheck \"Use base Name and Increment\"\n\n" + bracketNumberException.Message); }//End Catch on validating text in bracket } //Write single submit else { currentPage.title = txbPageName.Text; currentPage.body = Regex.Replace(rtbPageBody.Text, @"\[([^\]]*)\]", txbPageName.Text); var jsonString = $"{{\"wiki_page\":{JsonConvert.SerializeObject(currentPage)}}}"; restResult = await requester.MakePOSTRequestAsync(endPoint, jsonString); //Reset form for next submit nudCourseID.TabStop = false; txbBaseName.TabStop = false; //Write Results to Text box rtbResults.AppendText(String.Format("{0,-50} {1,-10}\n", txbPageName.Text, "Created")); } // end else } //End Single Submit catch (Exception apiException) { rtbResults.AppendText("Submit Failed: " + apiException.Message + "\n"); } }//End Submit
}//End Control items in response combo box //submit Button private async void btnSubmitQuiz_Click(object sender, EventArgs e) { //create variables string restResult = "No Call Made"; //this will be over written by results from web call string endPoint = Properties.Settings.Default.InstructureSite + "/api/v1/courses/" + Convert.ToString(nudCourseID.Value) + "/quizzes?"; //Get base endpoint from setting Requester requester = new Requester(); int quizesToMake = Convert.ToInt32(nudNumberOfQuiz.Value); int quizNumber = 0; currentQuiz.quiz_type = currentQuiz.QuizType(Convert.ToString(cbxQuizType.SelectedItem)); //Getting key back currentQuiz.assignment_group_id = (from kvp in assignmentGroupvalues where kvp.Value == Convert.ToString(cbxAssignmentGroup.SelectedItem) select kvp.Key).FirstOrDefault(); currentQuiz.time_limit = currentQuiz.QuizTimeLimit(xbxTimeLimit.Checked, Convert.ToInt32(nudMinutes.Value)); currentQuiz.shuffle_answers = xbxShuffle.Checked; currentQuiz.hide_results = currentQuiz.HideResults(xbxQuizResponses.Checked, xbxOnlyAfterLastAttempt.Checked); currentQuiz.show_correct_answers = xbxSeeCorrectAnswers.Checked; currentQuiz.show_correct_answers_last_attempt = xbxCorrectAnswersAfterLastAttempt.Checked; currentQuiz.show_correct_aswers_at = currentQuiz.ShowCorrectAnswerAt(xbxSeeCorrectAnswers.Checked, dtpShow.Checked, dtpShow.Value, dtpShowTime.Value); currentQuiz.hide_correct_answers_at = currentQuiz.HideCorrectAnswerAt(xbxSeeCorrectAnswers.Checked, dtpHide.Checked, dtpHide.Value, dtpHideTime.Value); currentQuiz.allowed_attempts = currentQuiz.AllowedAttempts(xbxAttempts.Checked, xbxLimitAttempts.Checked, Convert.ToInt32(nudAttempts.Value)); currentQuiz.scoring_policy = currentQuiz.ScoringPolicy(Convert.ToString(cbxScoreToKeep.SelectedItem)); currentQuiz.one_question_at_a_time = xbxOneQuestionTime.Checked; currentQuiz.cant_go_back = currentQuiz.CantGoBack(xbxOneQuestionTime.Checked, xbxLockQuestion.Checked); currentQuiz.access_code = currentQuiz.AccessCode(xbxAccessCode.Checked, txbAccessCode.Text); currentQuiz.ip_filter = currentQuiz.IpAddressFiltering(xbxIPAddresses.Checked, txbIPAddresses.Text); currentQuiz.one_time_results = currentQuiz.OneTimeResults(xbxQuizResponses.Checked, xbxOnlyOnce.Checked); currentQuiz.require_lockdown_browser = xbxRequireLockDownBowser.Checked; currentQuiz.require_lockdown_browser_for_results = currentQuiz.RequireLockdownBrowsertoVeiwResults(xbxRequireLockDownBowser.Checked, xbxRequireLockDownBrowsertoViewResuts.Checked); currentQuiz.due_at = currentQuiz.DueDate(dtpDueDate.Checked, dtpDueDate.Value, dtpDueDateTime.Value); currentQuiz.unlock_at = currentQuiz.UnlockDate(dtpUnlockDate.Checked, dtpUnlockDate.Value, dtpUnlockDateTime.Value); currentQuiz.lock_at = currentQuiz.LockDate(dtpLockDate.Checked, dtpLockDate.Value, dtpLockDateTime.Value); currentQuiz.published = xbxPublish.Checked; //Make API Call try { //Write out submit header rtbResults.AppendText(String.Format("{0,-50} {1,-10}\n", "Quiz Name", "Status")); //Write Repeating submit if (xbxUseBase.Checked == true) { try { //Validate Number in text var pattern = @"\[([^\]]*)\]"; var inputNumber = Regex.Match(txbBaseName.Text, pattern).Value.Replace("[", "").Replace("]", ""); quizNumber = Convert.ToInt32(inputNumber); //While loop to run until Quizzes to make is zero try { for (int loopIndex = 1; loopIndex <= quizesToMake; loopIndex++) { //Incrementing quiz number currentQuiz.title = Regex.Replace(txbBaseName.Text, @"\[([^\]]*)\]", Convert.ToString(quizNumber)); //Formating Quiz Description for HTML currentQuiz.description = Regex.Replace(rtbQuizInstructions.Text, @"\[([^\]]*)\]", currentQuiz.title); //REST Call var jsonString = $"{{\"quiz\":{JsonConvert.SerializeObject(currentQuiz)}}}"; //restResult = await requester.MakeRequestAsync(endPoint, Properties.Settings.Default.CurrentAccessToken, quizTitleParameter + allParameters + quizDescriptionParameter); restResult = await requester.MakePOSTRequestAsync(endPoint, jsonString); //Write Results to Text box rtbResults.AppendText(String.Format("{0,-50} {1,-10}\n", currentQuiz.title, "Created")); quizNumber++; }//End Repeating submit while statement //Clear QuizNames txbBaseName.Text = ""; txbQuizName.Text = ""; }//End try catch (Exception apiException) { MessageBox.Show(apiException.Message); } }//End try On validating text in bracket catch (FormatException bracketNumberException) { MessageBox.Show("Please enter a number in brackets or uncheck \"Use base Name and Increment\"\n\n" + bracketNumberException.Message); }//End Catch on validating text in bracket } //Write single submit else { //Creating Quiz Title and making it HTML safe currentQuiz.title = txbQuizName.Text; //Formating Quiz Description for HTML currentQuiz.description = Regex.Replace(rtbQuizInstructions.Text, @"\[([^\]]*)\]", txbQuizName.Text); //restResult = await requester.MakeRequestAsync(endPoint, Properties.Settings.Default.CurrentAccessToken, quizTitleParameter + allParameters + quizDescriptionParameter); var jsonString = $"{{\"quiz\":{JsonConvert.SerializeObject(currentQuiz)}}}"; restResult = await requester.MakePOSTRequestAsync(endPoint, jsonString); //Reset form for next submit nudCourseID.TabStop = false; txbBaseName.TabStop = false; //Write Results to Text box rtbResults.AppendText(String.Format("{0,-50} {1,-10}\n", txbQuizName.Text, "Created")); }//End Single Submit } catch (Exception apiException) { rtbResults.AppendText("Submit Failed: " + apiException.Message + "\n"); } }//End Submit
}//End Control items in response combo box //submit Button private async void btnSubmitQuiz_Click(object sender, EventArgs e) { //create variables string restResult = "No Call Made"; //this will be over written by results from web call var tokenParameter = methods.AccessToken(); //Create string endPoint = Properties.Settings.Default.InstructureSite + "/api/v1/courses/" + Convert.ToString(nudCourseID.Value) + "/quizzes?"; //Get base endpoint from setting Requester requester = new Requester(); int quizesToMake = Convert.ToInt32(nudNumberOfQuiz.Value); int quizNumber = 0; //Setting methods var quizTypeParameter = methods.QuizType(Convert.ToString(cbxQuizType.SelectedItem)); //Getting key back var assignmentGroupKey = (from kvp in assignmentGroupvalues where kvp.Value == Convert.ToString(cbxAssignmentGroup.SelectedItem) select kvp.Key).FirstOrDefault(); var assignmentTypeParameter = methods.AssignmentGroup(assignmentGroupKey); var quizTimeLimitParameter = methods.QuizTimeLimit(xbxTimeLimit.Checked, Convert.ToInt32(nudMinutes.Value)); var shuffleAnswersParameter = methods.ShuffleAnswers(xbxShuffle.Checked); var hideResultsParameter = methods.HideResults(xbxQuizResponses.Checked, xbxOnlyAfterLastAttempt.Checked); var showCorrectAnswer = methods.ShowCorrectAnswer(xbxSeeCorrectAnswers.Checked); var showCorrectAnswerLastAttempt = methods.ShowCorrectAnswerLastAttempt(xbxCorrectAnswersAfterLastAttempt.Checked); var showCorrectAnswersAt = methods.ShowCorrectAnswerAt(xbxSeeCorrectAnswers.Checked, dtpShow.Checked, dtpShow.Value, dtpShowTime.Value); var hideCorrectAnswersAt = methods.HideCorrectAnswerAt(xbxSeeCorrectAnswers.Checked, dtpHide.Checked, dtpHide.Value, dtpHideTime.Value); var allowedAttempts = methods.AllowedAttempts(xbxAttempts.Checked, xbxLimitAttempts.Checked, Convert.ToInt32(nudAttempts.Value)); var scoringPolicy = methods.ScoringPolicy(Convert.ToString(cbxScoreToKeep.SelectedItem)); var oneQuestionAtATime = methods.OneQuestionAtATime(xbxOneQuestionTime.Checked); var cantGoBack = methods.CantGoBack(xbxOneQuestionTime.Checked, xbxLockQuestion.Checked); var accessCode = methods.AccessCode(xbxAccessCode.Checked, txbAccessCode.Text); var ipAddressFilter = methods.IpAddressFiltering(xbxIPAddresses.Checked, txbIPAddresses.Text); var oneTimeResults = methods.OneTimeResults(xbxQuizResponses.Checked, xbxOnlyOnce.Checked); var requireLockdownBrowser = methods.RequireLockdownBrowser(xbxRequireLockDownBowser.Checked); var requireLockdownBrowsertoView = methods.RequireLockdownBrowsertoVeiwResults(xbxRequireLockDownBowser.Checked, xbxRequireLockDownBrowsertoViewResuts.Checked); var dueDate = methods.DueDate(dtpDueDate.Checked, dtpDueDate.Value, dtpDueDateTime.Value); var unlockDate = methods.UnlockDate(dtpUnlockDate.Checked, dtpUnlockDate.Value, dtpUnlockDateTime.Value); var lockDate = methods.LockDate(dtpLockDate.Checked, dtpLockDate.Value, dtpLockDateTime.Value); var publishQuiz = methods.PublishQuiz(xbxPublish.Checked); //combining all parameters var allParameters = quizTypeParameter + assignmentTypeParameter + shuffleAnswersParameter + quizTimeLimitParameter + hideResultsParameter + showCorrectAnswer + showCorrectAnswerLastAttempt + showCorrectAnswersAt + hideCorrectAnswersAt + dueDate + unlockDate + lockDate + allowedAttempts + scoringPolicy + oneQuestionAtATime + cantGoBack + accessCode + ipAddressFilter + oneTimeResults + requireLockdownBrowser + publishQuiz + requireLockdownBrowsertoView; //rtbResults.AppendText(allParameters); //Make API Call try { //Validate fields //Write out submit header rtbResults.AppendText(String.Format("{0,-50} {1,-10}\n", "Quiz Name", "Status")); //Write Repeating submit if (xbxUseBase.Checked == true) { try { //Validate Number in text var pattern = @"\[([^\]]*)\]"; var inputNumber = Regex.Match(txbBaseName.Text, pattern).Value.Replace("[", "").Replace("]", ""); quizNumber = Convert.ToInt32(inputNumber); //While loop to run until Quizes to make is zero try { while (quizesToMake > 0) { //Incrementing quiz number var incrementedQuizName = Regex.Replace(txbBaseName.Text, @"\[([^\]]*)\]", Convert.ToString(quizNumber)); var htmlSafeIncrementedQuizName = Uri.EscapeDataString(incrementedQuizName); var quizTitleParameter = "&quiz[title]=" + htmlSafeIncrementedQuizName; //Formating Quiz Description for HTML var incrementedQuizInstruction = Regex.Replace(rtbQuizInstructions.Text, @"\[([^\]]*)\]", incrementedQuizName); var htmlSafeIncrementedQuizInstruction = Uri.EscapeDataString(incrementedQuizInstruction); var quizDescriptionParameter = methods.QuizDescription(htmlSafeIncrementedQuizInstruction); //REST Call restResult = await requester.MakeRequestAsync(endPoint, Properties.Settings.Default.CurrentAccessToken, quizTitleParameter + allParameters + quizDescriptionParameter); //Write Results to Text box rtbResults.AppendText(String.Format("{0,-50} {1,-10}\n", incrementedQuizName, "Created")); quizNumber++; quizesToMake--; }//End Repeating submit while statement //Clear QuizNames txbBaseName.Text = ""; txbQuizName.Text = ""; }//End try catch (Exception apiException) { MessageBox.Show(apiException.Message); } }//End try On validating text in bracket catch (FormatException bracketNumberException) { MessageBox.Show("Please enter a number in brackets or uncheck \"Use base Name and Increment\"\n\n" + bracketNumberException.Message); }//End Catch on validating text in bracket } //Write single submit else { //Creating Quiz Title and making it HTML safe var quizTitleParameter = "&quiz[title]=" + Uri.EscapeDataString(txbQuizName.Text); //Formating Quiz Description for HTML var incrementedQuizInstruction = Regex.Replace(rtbQuizInstructions.Text, @"\[([^\]]*)\]", txbQuizName.Text); //Makeing Quiz instruction HTML Safe var htmlSafeIncrementedQuizInstruction = Uri.EscapeDataString(incrementedQuizInstruction); //Setting quiz description parameter var quizDescriptionParameter = methods.QuizDescription(htmlSafeIncrementedQuizInstruction); restResult = await requester.MakeRequestAsync(endPoint, Properties.Settings.Default.CurrentAccessToken, quizTitleParameter + allParameters + quizDescriptionParameter); //Reset form for next submit nudCourseID.TabStop = false; txbBaseName.TabStop = false; //Write Results to Text box rtbResults.AppendText(String.Format("{0,-50} {1,-10}\n", txbQuizName.Text, "Created")); }//End Single Submit } catch (Exception apiException) { rtbResults.AppendText("Submit Failed: " + apiException.Message + "\n"); } }//End Submit
//Load course and user private async void btnLoadCourse_Click(object sender, EventArgs e) { try { //Ensure if there is active token if (Properties.Settings.Default.CurrentAccessToken != "No Access Token" && Properties.Settings.Default.CurrentAccessToken != "") { if (nudCourseID.Value == 1) { MessageBox.Show("Please Enter a Course ID"); } else { //allow user to input course name txbBaseName.Enabled = true; //Setting wait curser Cursor.Current = Cursors.WaitCursor; //Make Call to get user name if (Properties.Settings.Default.CurrentAccessToken != "No Access Token" && Properties.Settings.Default.CurrentAccessToken != "") { string profileObject = "name"; string userName = await getProfile.GetProfile(profileObject); //Print message labelLoggedIn.Text = "Logged in as " + userName; } else { labelLoggedIn.Text = "Not logged in"; } //Get course name try { //Get Course Name string endPoint = Properties.Settings.Default.InstructureSite + "/api/v1/courses/" + nudCourseID.Value + "?"; Requester requester = new Requester(); var json = await requester.MakeRequestAsync(endPoint, parameters.AccessToken()); //deserialize the JSON object dynamic jsonObj = JsonConvert.DeserializeObject(json); //parse the JSON object dynamic data = JObject.Parse(json); //Printing out results rtbResults.AppendText("Course " + Convert.ToString(data.name) + " has been selected!\n"); } catch (Exception courseIDChangeException) { rtbResults.AppendText(courseIDChangeException.Message + "\n"); } //Get list of modules for module position grid try { //reset modules listed courseModulesGrid.Columns.Clear(); courseModulesGrid.Refresh(); string endPoint = Properties.Settings.Default.InstructureSite + "/api/v1/courses/" + nudCourseID.Value + "/modules?";//Get endpoint Requester requester = new Requester(); var json = await requester.MakeRequestAsync(endPoint, Properties.Settings.Default.CurrentAccessToken); dynamic jsonObj = JsonConvert.DeserializeObject(json); courseModulesGrid.Columns.Add("moduleName", "Module Name"); courseModulesGrid.Columns.Add("modulePos", "Position"); courseModulesGrid.Columns[0].Width = 50; courseModulesGrid.Columns[1].Width = 50; foreach (var obj in jsonObj) { courseModulesGrid.Rows.Add(String.Format(Convert.ToString(obj.name)), (Convert.ToString(obj.position))); } courseModulesGrid.ClearSelection(); } //end try catch (Exception populateModulesGridException) { MessageBox.Show(populateModulesGridException.Message + "\n"); } //End Wait Cursor Cursor.Current = Cursors.Default; } }//end token check if else { MessageBox.Show("Not logged in. Enter valid token", "Authentication error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }//end try catch (Exception apiException) { MessageBox.Show("Token not authorized. Input valid token.\n" + apiException.Message, "Authentication error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }//End Load Course Click
private async void btnSubmitModule_Click(object sender, EventArgs e) { try { string restResult = "No Call Made"; //this will be over written by results from web call var tokenParameter = parameters.AccessToken(); //Create string endPoint = Properties.Settings.Default.InstructureSite + "/api/v1/courses/" + nudCourseID.Value + "/modules?"; //Get endpoint Requester requester = new Requester(); int moduleToMake = Convert.ToInt32(nudNumberOfModule.Value); int moduleNumber = 0; var requireSequentialProgress = parameters.SequentialProgress(seqProgress.Checked); var dateToUnlock = parameters.UnlockDate(unlockOnDate.Checked, datePicker.Value); var modulePostion = parameters.ModulePosition(setModulePos.Checked, nudModulePos.Value); //combining all parameters var allParameters = requireSequentialProgress + dateToUnlock + modulePostion; //Make API Call try { //Validate fields //Write out submit header rtbResults.AppendText(String.Format("{0,-50} {1,-10}\n", "Module Name", "Status")); //Write Repeating submit if (xbxUseBase.Checked == true) { try { //Validate Number in text var pattern = @"\[([^\]]*)\]"; var inputNumber = Regex.Match(txbBaseName.Text, pattern).Value.Replace("[", "").Replace("]", ""); moduleNumber = Convert.ToInt32(inputNumber); //While loop to run until modules to make is zero try { while (moduleToMake > 0) { //Incrementing assignment number var incrementedModuleName = Regex.Replace(txbBaseName.Text, @"\[([^\]]*)\]", Convert.ToString(moduleNumber)); var htmlSafeIncrementedModuleName = Uri.EscapeDataString(incrementedModuleName); var moduleTitleParameter = "&module[name]=" + htmlSafeIncrementedModuleName; restResult = await requester.MakeRequestAsync(endPoint, Properties.Settings.Default.CurrentAccessToken, moduleTitleParameter + allParameters); //Write Results to Text box rtbResults.AppendText(String.Format("{0,-50} {1,-10}\n", incrementedModuleName, "Created")); moduleNumber++; moduleToMake--; }//End Repeating submit while statement //Clear Module Names txbBaseName.Text = ""; txbModuleName.Text = ""; }//End try catch (Exception apiException) { MessageBox.Show(apiException.Message); } }//End try On validating text in bracket catch (FormatException bracketNumberException) { MessageBox.Show("Please enter a number in brackets or uncheck \"Use base Name and Increment\"\n\n" + bracketNumberException.Message); }//End Catch on validating text in bracket } //Write single submit else { //Creating Module Name and making it HTML safe var moduleNameParameter = "&module[name]=" + Uri.EscapeDataString(txbModuleName.Text); MessageBox.Show(tokenParameter + moduleNameParameter + allParameters); restResult = await requester.MakeRequestAsync(endPoint, Properties.Settings.Default.CurrentAccessToken, moduleNameParameter + allParameters); //Reset form for next submit nudCourseID.TabStop = false; txbBaseName.TabStop = false; //Write Results to Text box rtbResults.AppendText(String.Format("{0,-50} {1,-10}\n", txbModuleName.Text, "Created")); } // end else } //End Single Submit catch (Exception apiException) { rtbResults.AppendText("Submit Failed: " + apiException.Message + "\n"); } } //end try catch (Exception apiException) { MessageBox.Show("Token not authorized. Input valid token.\n" + apiException.Message, "Authentication error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }