Hi All,
I am facing the problem of passing the JSON object to my Java REST service. Here is what the steps I followed.
I created a Java REST Service to create a customer
@POST
@Override
@Consumes({MediaType.APPLICATION_JSON})
@Produces({MediaType.APPLICATION_JSON})
public Customer create(Customer entity) {
System.out.println("Comeing in POST service for Create customer.."+entity.getCustomerId());
super.create(entity);
return entity;
}
I followed the Common model in the cookbook as well.
I formed the customer json in my JET application and trying to invoke this method, it is not coming inside the method. I placed a filter to allow the headers to get the data. Unfortunately while accessing the post method, the request is not even going into filter.
wrappedResponse.addHeader("Access-Control-Allow-Origin", "*");
wrappedResponse.addHeader("Access-Control-Allow-Credentials", "true");
wrappedResponse.addHeader("Access-Control-Allow-Methods", "GET, POST, DELETE, PUT");
wrappedResponse.addHeader("Access-Control-Allow-Headers", "Content-Type, Access-Control-Allow-Headers, Authorization, X-Requested-With");
Below is the code that I used to invoke the post method
self.buttonClick = function(data, event){
var viewModel = ko.toJSON(data);
var someModel = JSON.parse(viewModel);
url = "http://localhost:8080/restforjet/webresources/customer";
console.log(viewModel);
console.log(someModel);
$.post({
url: url,
type: "POST",
data: someModel,
dataType: "text/html",
success: function(result){
console.log(result);
},
error: function(){
console.log('Error');
}
});
We have to give a customer Demo to promote OracleJET as the customer is having full REST services and we recommended Oraclejet for UI. Any help is highly appreciated.
Regards,
-Venkat
Message was edited by: user8898068