Reputation: 2727
I'm designing a REST Api for a testing software and I have a doubt. I searched a lot but it's not clear enough for me. My scenario is a queue which contains multiple jobs to be printed. These jobs are complex objects and the printing workflow is another complex action. I don't know which operation fit best to this. According to this, it should be a POST?
http://restful-api-design.readthedocs.org/en/latest/methods.html
In this case my action will fit better into an RPC model but we need to use REST according to that 95% of actions fits perfectly to this model.
In case that is a POST I must send the queue that I want to print inside the body?
Thank you so much.
Upvotes: 2
Views: 692
Reputation: 202266
I don't know what you want to expose through your REST API but I would think about this.
You could expose a resource with path /printjobs
that corresponds to the print queue. Using a method POST
would add a job in the queue. The returned status code would be 202 Accepted
since it's something asynchronous and return an identifier for the new job.
Something in background would be responsible to handle job in the queue. I think that it's something different from the REST API.
Then you could use a resource /printjobs/{id}
that will give you hints about the status of the job (method GET
), suppress it (method DELETE
) and update its status (for example to suspend it with method PUT
or PATCH
)/
Hope it helps you, Thierry
Upvotes: 2