I want to execute a POST request from AngularJS to a Jersey REST server. This is the server code.
@POST
@Path("/start")
public Response start(@FormParam("name") String name) {
System.out.println(name);
return Response.status(200).entity("Finished starting").build();
}
and this is the AngularJS code
$scope.submitForm = function() {
var url = 'http://localhost:8080/Server/config/start';
var request = $http({method: 'POST', url: url,
params:{name: 'test'}});
request.success(
function() {
//alert('it succeeded');
}
);
request.error(
function() {
// alert('it didnt work');
}
);
};
I receive the request on the server but the parameter name
is always null
. Is it possible to solve the problem without changing the way of receiving the parameter on the server side (the @FormParam
)? When I try the REST resource with a REST client RESTClient
in firefox everything works fine.
As I said the server receive the request and execute it, however I get an error on the AnularJS side, I don't know if it's related to the null problem, I think no because even if I change the a no-existing resource I get the same warning.
EDIT:
I solved the CORS issue but the received parameter is still null.