Ajax Call return success but no data added to database

15 views
Skip to first unread message

Peter Wong

unread,
Sep 10, 2018, 2:25:10 PM9/10/18
to google-http-java-client
Dear All, 
Our developers have coded an ajax call to add contact to database and I need to test this function. Please look at the AddContact.js with function AddContact().

My Code is here.
try {
     
String requestBody = "{'Source': 'Contact', 'MethodName': 'AddContact', 'UserID': '1', 'SalutationID': '1', 'FirstName': 'Peter', "
                                       
+ "'LastName': 'Wong', 'JobTitle': 'Software QA', 'PrimaryEmail': 'peter...@gmail.com', "
                                       
+ "'BusinessPhone': '60163963326', 'CountryID': '104', 'OrganizationID': '1', 'AOIIDs': '2'}";
                       
   
  GenericUrl url = new GenericUrl("https://extranet-uat.who.int/epqs/Main/ServiceProxy");
    HttpRequestFactory rf = new NetHttpTransport().createRequestFactory();
     
HttpRequest request = rf.buildPostRequest(url, ByteArrayContent.fromString("application/json",
                                        requestBody
));
     request
.getHeaders().setContentType("application/json");
     
HttpResponse response = request.execute();
                       
     
SoftAssert sAssert = new SoftAssert();
     sAssert
.assertEquals(response.getStatusCode(), 200);
     
System.out.println("HTTP Status Code : " + response.getStatusCode());
                       
     
} catch (IOException ex) {
       
LogManager.logger.log(Level.INFO, "Exception: " + ex.getMessage());
     
}


Please help me. Thanks. 

Reply all
Reply to author
Forward
0 new messages