0

I use Play Framework 2.2.X.

Is it possible to map this route?:

POST /api/constructors/:constructorId/cars  CarCrudController.create(constructorId)

I get a BadRequest (code 400) when hitting this route.

IMO, it seems that Play allows nested resources only for reads: GET instead of POST.

Is it possible?

Mik378
  • 21,881
  • 15
  • 82
  • 180
  • I've just found some hints about: https://groups.google.com/forum/#!topic/play-framework/iR9yNwU-bSI but no strict answer. – Mik378 Jun 01 '14 at 23:01
  • I think your problem may be elsewhere. I don't see any reason not to have that kind of URL. I have for example /teacher/:schoolId/upload which works. Make sure that one of your other URLs it not obscuring it? – wwkudu Jun 02 '14 at 03:55
  • @wwkudu Can you post a Gist with a simple example which would work? – Mik378 Jun 02 '14 at 06:21
  • Not sure what all to publish - can I suggest you publish what's not working and we can look at it? – wwkudu Jun 02 '14 at 11:38
  • @wwkudu Thanks, I succeeded to make it work. Was a bad configuration. – Mik378 Jun 02 '14 at 17:19

1 Answers1

1

Nested routes are supported in any HTTP method. You can checkout the samples from the github for some examples. The computer-database example, has the following routes.conf:

# Delete a computer
POST    /computers/:id/delete       controllers.Application.delete(id:Long)

The bad request response could be related with the content-type of your request or the post content itself, and nothing to do with the nested routes.

Didac Montero
  • 2,046
  • 19
  • 27
  • Thanks guys. I was using Restangular (JS library) in order to call my backend with this kind of nested routes. Fixed it and it works ;) – Mik378 Jun 02 '14 at 17:19