First you must define entities for yourself or technically / simply (but not exactly) tables to store your data.
I assume it will be something like:
- students - a table for students
- grades - student grades here Courses
- - there will be a course schedule.
Further, the idea of ββREST is that the record is managed (updated / inserted / deleted) individually. Data is transferred as raw JSON in the content body for a particular record. However, you can also process multiple entries in a batch. For example, if on an insert (POST method) you pass an array of JSON and not an object, that is, you send several records, then you make several attachments to the end: inserting a student will take something like this: {"name": "John"} , but the insertion of several students will look something like this: [{"name": "John"}, {"name": "Davy"}]
Usually in REST, you do not need to upload JSON files yourself, you pass the data as JSON to the service. Think twice if you really need to load data into JSON as files. However, this is technically possible. In the case of file downloads, you need to transfer the data in the form, and not in the form of source code, as the classic REST approach.
Later, define a URI for each object, for example, for students it will be something like /api/students/[id/] with REST style functionality based on the HTTP method:
- GET - a list of all recordsets or individual (/ students / 5 /)
- POST - insert a new entry with JSON from the body
- PUT - updating a specific record, usually with an identifier, for example (/ students / 5 /)
- DELETE - delete a record from a set of records, usually with an identifier, for example (/ students / 5 /)
GETs can be improved with filtering, swapping, etc. And, of course, you have to take care of security, data access / management level management.
For operations targeting individual write operations, such as editing / deleting, the record identifier can be passed in part of the URI or as a parameter or in the content body. You decide.
Marcodor
source share