• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

RESTful URI naming questions

 
K Mansoor
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Folks- I'm confused about how to name a URI for this simple situation:

Let's say my website allows users to manipulate books (resources). I can use something like the following to add a book:


to delete:


and so on, now i have a menu item in the navigation bar which says, "Click here to create a book', what I want to do is to take the user to a page which displays a form, allowing the user to enter a new book info and when submit is pressed, the form will be POST'ed to:

Question is what URL to use for "Click here to create a book"?

is the following RESTful?
www.localhost:8080/bookz/book/new

Is there a convention for this?

Thank you.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64717
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
/new is not RESTful because it's not addressing a resource.

I'd use something like /books/book/book-name, and I'd use a PUT rather than POST.
 
K Mansoor
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can you please explain a bit the last element in /books/book/book-name (/book-name)? this can be an indication to the server to display a form to create a new book?

Thank you.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64717
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I thought you wanted to create the book, not display a form.
 
K Mansoor
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to display a form, which will allow user to enter information to create a book resource. Not sure how to name a url to display an 'Add a new book' form.

Thank you.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64717
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'll let someone else handle that.

None of my RESTful APIs have a UI. Rather, I have a separate web app that handles the UI, and uses the UI-agnostic RESTful API (which has multiple clients including web apps, iPhone apps, Android, and so on).

 
Dan Drillich
Ranch Hand
Posts: 1183
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
... the form will be POST'ed to www.localhost:8080/bookz/book


makes perfect sense to me.

Question is what URL to use for "Click here to create a book"?

As Bear pointed out, it seems to be an auxiliary url and doesn't seem to fall easily into this paradigm, as the url structure is about the resource. However, looking at rest/urls supports you all the way. It says -


Operate on the Collection
GET /people
return a list of all records
GET /people/new
return a form for creating a new record
POST /people
submit fields for creating a new record


How to create a REST Protocol is also useful.

Regards,
Dan
 
K Mansoor
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you, this is exactly what I needed.
 
Robert Morschel
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I posted a set of guidelines that we use here: http://soaprobe.blogspot.co.uk/2012/10/soa-rest-service-naming-guideline.html

I hope that helps.

Robert
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic