Site Tools


guides:sample_submitterrequest_snippet

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
guides:sample_submitterrequest_snippet [2023/03/20 22:32] brett.zamoraguides:sample_submitterrequest_snippet [2024/01/12 19:25] (current) brett.zamora
Line 2: Line 2:
 private void createNewSubmitterRequest() private void createNewSubmitterRequest()
 { {
-    string strNewRequestID = "0";+            string strNewRequestID = "0";
  
-    RestClient client = null; +            RestClient client = null; 
-    RestRequest request = null; +            RestRequest request = null; 
-    IRestResponse response = null;+            IRestResponse response = null;
  
-    string strURL = "https://" + getHost() + "/APEX/Service/APEXPublicServer.svc/user/login";+            string strURL = "https://" + getHost() + "/APEX/Service/APEXPublicServer.svc/user/login";
  
-    // Password has to be hashed. +            // Password has to be hashed. 
-    // New convention uses a Salt value from the user record+            // New convention uses a Salt value from the user record
  
-    string strSalt = GetSalt(tbUserName.Text); +            string strSalt = GetSalt(tbUserName.Text); 
-    string strPassword = tbPassword.Password.ToString();+            string strPassword = tbPassword.Password.ToString();
  
-    string strHashedPassword = HashPassword(strPassword, strSalt);+            string strHashedPassword = HashPassword(strPassword, strSalt);
  
-    string strParms = "{\n\t\"user_name\" : \""; +            string strParms = "{\n\t\"user_name\" : \""; 
-    strParms += tbUserName.Text; +            strParms += tbUserName.Text; 
-    strParms += "\",\n\t\"password\" : \""; +            strParms += "\",\n\t\"password\" : \""; 
-    strParms += strHashedPassword; +            strParms += strHashedPassword; 
-    strParms += "\"\n}";+            strParms += "\"\n}";
  
-    client = new RestClient(strURL); +            client = new RestClient(strURL); 
-    request = new RestRequest(Method.POST);+            request = new RestRequest(Method.POST);
  
-    request.AddHeader("Cache-Control", "no-cache"); +            request.AddHeader("Cache-Control", "no-cache"); 
-    request.AddHeader("Content-Type", "application/json");+            request.AddHeader("Content-Type", "application/json");
  
-    request.AddParameter("Login", strParms, ParameterType.RequestBody); +            request.AddParameter("Login", strParms, ParameterType.RequestBody); 
-    response = client.Execute(request);+            response = client.Execute(request);
  
-    if (response.IsSuccessful)  // Successfully logged in and a token has been provided +            if (response.IsSuccessful)  // Successfully logged in and a token has been provided 
-    +            
-        var jsonResult1 = JsonConvert.DeserializeObject<dynamic>(response.Content); +                var jsonResult1 = JsonConvert.DeserializeObject<dynamic>(response.Content); 
-        string token = jsonResult1.access_token;+                string token = jsonResult1.access_token;
  
-        strURL = null; +                strURL = null; 
-        client = null; +                client = null; 
-        request = null; +                request = null; 
-        response = null;+                response = null; 
 +                 
 +                // Note: Be sure to escape your PrimaryName, Address1, and Address2 values to avoid issues associated with invalid HTML characters appearing in the URL.
  
-        // Note: Be sure to escape your PrimaryName, Address1, and Address2 values to avoid issues associated with invalid HTML characters appearing in the URL.+                strURL = "https://" + getHost() + "/APEX/Service/APEXPublicServer.svc/submitterRequest";
  
-        strURL = "https://" + getHost() + "/APEX/Service/APEXPublicServer.svc/submitterRequest"; +                if (tbRequestID.Text == "" || tbRequestID.Text =" " || tbRequestID.Text == "0") 
-        strURL strURL + "?" + "RequestID=0"+                { 
-        strURL = strURL + "&" + "SubmitterTypeID=" + tbSubmitterTypeValue.Text+                    strURL = strURL + "?" + "RequestID=0"; 
-        strURL strURL + "&+ "PrimaryName=" + Uri.EscapeDataString(tbSubmitterName.Text); +                } 
-        strURL strURL + "&" + "Address1=" + Uri.EscapeDataString(tbAddress1.Text); +                else 
-        strURL = strURL + "&" + "Address2=" + Uri.EscapeDataString(tbAddress2.Text); +                { 
-        strURL = strURL + "&" + "City=" + tbCity.Text; +                    strURL = strURL + "?" + "RequestID=" + tbRequestID.Text; 
-        strURL = strURL + "&" + "StateName=" + tbState.Text+                }
-        strURL = strURL + "&" + "PostalCode=" + tbZipCode.Text; +
-        strURL = strURL + "&" + "COIExpirationDate="+tbCOIExpires.Text;+
  
-        client new RestClient(strURL); +                strURL strURL + "&" + "SubmitterTypeID=" + tbSubmitterTypeValue.Text; 
-        request new RestRequest(Method.POST);+                strURL = strURL + "&" + "PrimaryName=" + Uri.EscapeDataString(tbSubmitterName.Text); 
 +                strURL = strURL + "&" + "Address1=" + Uri.EscapeDataString(tbAddress1.Text); 
 +                strURL strURL + "&" + "Address2=" + Uri.EscapeDataString(tbAddress2.Text)
 +                strURL = strURL + "&" + "City=" + tbCity.Text; 
 +                strURL = strURL + "&" + "StateName=" + tbState.Text; 
 +                strURL = strURL + "&" + "PostalCode=" + tbZipCode.Text; 
 +                strURL = strURL + "&" + "COIExpirationDate="+tbCOIExpires.Text;
  
-        request.AddHeader("Cache-Control", "no-cache"); +                // The following 2 properties have been added since the original release of the web service 
-        request.AddHeader("access_token"token); +                // If customers using the web service do not include these propertiestheir service call may not complete.
-        request.AddHeader("content-type", "text/plain"); +
-        response = client.Execute(request);+
  
-        if (response.IsSuccessful+                if (tbSubmitterTypeValue.Text == "32"
-        +                
-            var jsonResult2 JsonConvert.DeserializeObject<dynamic>(response.Content);+                    strURL strURL + "&" + "UpdateMOU=true"; 
 +                    strURL = strURL + "&" + "UpdateCOI=true"; 
 +                } 
 +                else 
 +                { 
 +                    strURL = strURL + "&" + "UpdateMOU=true"; 
 +                    strURL = strURL + "&" + "UpdateCOI=false"; 
 +                }
  
-            strNewRequestID jsonResult2.result+                client new RestClient(strURL)
-            tbRequestID.Text = strNewRequestID; +                request = new RestRequest(Method.POST);
-        } +
-    }+
  
-    return;+                request.AddHeader("Cache-Control", "no-cache"); 
 +                request.AddHeader("access_token", token); 
 +                request.AddHeader("content-type", "text/plain"); 
 +                //request.AddHeader("content-type", "application/x-www-form-urlencoded"); 
 +                response = client.Execute(request); 
 + 
 +                if (response.IsSuccessful) 
 +                { 
 +                    var jsonResult2 = JsonConvert.DeserializeObject<dynamic>(response.Content); 
 + 
 +                    strNewRequestID = jsonResult2.result; 
 +                    tbRequestID.Text = strNewRequestID; 
 +                } 
 +            } 
 + 
 +            return;
 } }
 </code> </code>
guides/sample_submitterrequest_snippet.1679351521.txt.gz · Last modified: by brett.zamora