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