guyja
guyja

Reputation: 917

Should I PUT, POST and DELETE against the resource URL I made a GET request against if I requested a collection from a nested route?

I have a question about designing REST APIs.

Lets say that GET /schools/1/students returns all students from a school with the id of 1.

Should POST, PUT and DELETE requests be sent to /schools/1/students to manipulate student resources going forward or to /students?

Upvotes: 0

Views: 39

Answers (1)

Andrew Paramoshkin
Andrew Paramoshkin

Reputation: 989

GET all students - /schools/1/students
GET one student - /schools/1/students/:student_id
POST - create new student (/schools/1/students)
PUT - update ONE student (/schools/1/students/:student_id)
DELETE - delete ONE student (/schools/1/students/:student_id)

Upvotes: 2

Related Questions