I am starting a new project and I was trying to figure out if I should follow a RESTful approach or not. By reading different sources on the internet I am getting more and more confused on how a truly RESTful approach should be. Some people say that the REST request (ie, both the URI and the rest of the content of the HTTP request) should never describe an action with something other than the HTTP verbs. Some others say that since the HTTP verbs are limited, the HTTP request body can provide additional info regarding which action need to be applied on the data described by the URI. Which of the two is correct? I will give you a simplified description of the software I am trying to build and how I think it should implemented with REST: The user must be able to upload/delete/edit data on the server. Then, he must be able to perform 10 different kinds of analysis (analysis01-analysis10) on the server in the form of jobs. So, the user will be submitting jobs to the server. When the jobs are finished the user will be able to get the results of the analysis. So here is how I think is the right way of implementing this in REST:
POST /datasets/ - To create/upload a new dataset GET /datasets/ - To get a list of all the available datasets. GET /datasets/01 - To get info about dataset 01 DELETE /datasets/01 - To delete dataset 01
POST /analysis01_jobs/ - Submit a new job for analysis01 GET /analysis01_jobs/ - Get a list with all the submitted analysis01 jobs GET /analysis10_jobs/ - Get a list with all the submitted analysis10 jobs GET /analysis01_jobs/01 - Get the status of job '01' which performs analysis of type 01 DELETE /analysis10_jobs/01 - Delete/Cancel job '01' which performs analysis of type 10
As you can see each type of analysis has a different REST URL path for the jobs. I was thinking to change this and put all jobs under the same path: "/analysis_jobs/" and specify the type of analysis I want inside the HTTP header. But this will imply the type of action I want the server to perform. Thus this this is not RESTful any more. Right or wrong?
When a job is complete it will produce a "result" resource. So the REST API for this will be something like this:
- There is no POST here because only the job that runs on the server can generate results. GET /analysis01_results/ - To get a list of all the available results from analysis01 jobs GET /analysis01_results/01 - To get the results of a job that performed analysis of type 01. The body of the HTTP response will also contain info about the "parent" job and data. DELETE /analysis01_results/01 - To delete the above results.
Is the above design RESTful?
Thank you in advance!