-
Notifications
You must be signed in to change notification settings - Fork 113
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Posting a new subresource,do I need a custom route? #72
Comments
POST is not allowed for a subresource. You should do a PUT with the ID of First POST the new player to the player resource. You should get back the That is the standard REST way to do this and should work for you. Thanks On Saturday, November 23, 2013, Spiros Kabasakalis wrote:
|
I see.I understand this,but my concern is that it needs 2 roundtrips to the server.Do you think I could handle this with a custom route? Something like POST /api/team/players/{team_id}
I assumed that the active-record-relation behavior that your extension uses can handle this. |
Sure it's possible. It's not particularly "RESTFull" but I guess so what... That said I would not get hung up on the extra round trip. These are supper Thanks On Saturday, November 23, 2013, Spiros Kabasakalis wrote:
|
O' You could handle this with a custom route (like the one you wrote above) for sure if you want to make a Good Luck! On Saturday, November 23, 2013, evan frohlich wrote:
|
I see.If I am too lazy,I'll take up the POST-player and PUT-player-to-team approach,sounds pretty straightforward.If I have more time,I might also try a custom route. |
No problem. I was in Athens last year and loved it! Cheers from New York City (Astoria: huge Greek community), USA. On Saturday, November 23, 2013, Spiros Kabasakalis wrote:
|
Following your team/players example in Subresources section of your readme file,
and assuming I have a MANY_MANY relationship,I 'd like to POST a new player in ,say team 3.Is this possible?I tried
POST /api/team/3/players/ with the new player as payload and got '405', 'Method Not Allowed' exception.After some digging in your code I think this is because a second parameter for the subresource (primary key) is expected,which makes sense if it's a GET,but not with POST obviously since it's a new record.POSTing to a subresource is not covered in this section.
Am I missing something here or should I declare a custom route to handle this ?
Thanks in advance.
The text was updated successfully, but these errors were encountered: