user3334226
user3334226

Reputation: 151

Play 2.7 http request post request

I am trying to do post request in play framework. Below is my sample code

routes.conf:

POST  /movies/add        controllers.MovieController.add()

controller:

public Result add(Request request) { 
    System.out.println("BODY:::"+request.body().toString());
    return ok();
}

I get below error

not enough arguments for method add: (x$1: play.mvc.Http.Request)play.mvc.Result.

What am i missing here to make this work?

Upvotes: 0

Views: 642

Answers (1)

John Brandli
John Brandli

Reputation: 110

Your add method is expecting a request object but its not in the route. I based this on the post example in the link below.

POST /movies/add controllers.MovieController.add(request: Request)

https://www.playframework.com/documentation/2.7.x/JavaFileUpload#Uploading-files-in-a-form-using-multipart/form-data

Upvotes: 1

Related Questions