Getting parameters from jQuery POST in Java Play Framework

I am trying to get parameters from a POST request using Java Play Framework (2.3.x).

Here is my request:

$.post(
    "/some/endpoint",
    {
        "thingId": 12345,
        "otherThingId": 1234
    },
    function (data) { /* Do some stuff. */ },
    "json"
);

      

And this is in my controller:

public static Result SomeEndpoint() {
    DynamicForm params = Form.form().bindFromRequest();

    System.out.println(params.get("thingId"));
    System.out.println(params.get("otherThingId"));
}

      

Unfortunately I never get any of the parameters I am trying to send. Does anyone know what I am doing wrong?

Thank!

+3


source to share


1 answer


All I can say is that I am doing the same to extract data from a post.

Have you tried compiling the project on the sbt command line?



You have a route like this:

POST /some/endpoint controllers.MyController.SomeEndpoint()

      

0


source







All Articles