private void updateMOUCOIRequest() { string strUpdateRequestID = "0"; RestClient client = null; RestRequest request = null; IRestResponse response = null; string strURL = "https://" + getHost() + "/APEX/Service/APEXPublicServer.svc/user/login"; // Password has to be hashed. // New convention uses a Salt value from the user record string strSalt = GetSalt(tbUserName.Text); string strPassword = tbPassword.Password.ToString(); string strHashedPassword = HashPassword(strPassword, strSalt); string strParms = "{\n\t\"user_name\" : \""; strParms += tbUserName.Text; strParms += "\",\n\t\"password\" : \""; strParms += strHashedPassword; strParms += "\"\n}"; client = new RestClient(strURL); request = new RestRequest(Method.POST); request.AddHeader("Cache-Control", "no-cache"); request.AddHeader("Content-Type", "application/json"); request.AddParameter("Login", strParms, ParameterType.RequestBody); response = client.Execute(request); if (response.IsSuccessful) // Successfully logged in and a token has been provided { var jsonResult1 = JsonConvert.DeserializeObject(response.Content); string token = jsonResult1.access_token; strURL = null; client = null; request = null; response = null; strURL = "https://" + getHost() + "/APEX/Service/APEXPublicServer.svc/updateMOUCOIRequest"; if (tbRequestID.Text == "" || tbRequestID.Text == " " || tbRequestID.Text == "0") { strURL = strURL + "?" + "RequestID=0"; } else { strURL = strURL + "?" + "RequestID=" + tbRequestID.Text; } strURL = strURL + "&" + "COIExpirationDate=" + tbCOIExpires.Text; strURL = strURL + "&" + "SubmitterID=" + tbSubmitterID.Text; strURL = strURL + "&" + "Address1=" + tbAddress1.Text; strURL = strURL + "&" + "Address2=" + tbAddress2.Text; strURL = strURL + "&" + "City=" + tbCity.Text; strURL = strURL + "&" + "StateName=" + tbState.Text; // This property needs to be changed to StateName (2 character state abbreviation.) strURL = strURL + "&" + "PostalCode=" + tbZipCode.Text; if ((bool)cbUpdateMOU.IsChecked) { strURL = strURL + "&" + "UpdateMOU=true"; } else { strURL = strURL + "&" + "UpdateMOU=false"; } if ((bool)cbUpdateCOI.IsChecked) { strURL = strURL + "&" + "UpdateCOI=true"; } else { strURL = strURL + "&" + "UpdateCOI=false"; } client = new RestClient(strURL); request = new RestRequest(Method.POST); request.AddHeader("Cache-Control", "no-cache"); request.AddHeader("access_token", token); request.AddHeader("content-type", "text/plain"); response = client.Execute(request); if (response.IsSuccessful) { var jsonResult2 = JsonConvert.DeserializeObject(response.Content); strUpdateRequestID = jsonResult2.result; tbRequestID.Text = strUpdateRequestID; if ((bool)cbUpdateMOU.IsChecked) { // Increase the test count below to validate that runaway calls are being protected. int testCtr = 0; for (testCtr = 0; testCtr < 1; testCtr++) { // Note the following syntax sendPDFFile("MOURequest"); } } if ((bool)cbUpdateCOI.IsChecked) { // Increase the test count below to validate that runaway calls are being protected. int testCtr = 0; for (testCtr = 0; testCtr < 1; testCtr++) { // Note the following syntax sendPDFFile("COIRequest"); } } } } return; }