rest - RESTful API and real life example -


we have web application (angularjs , web api) has quite simple functionality - displays list of jobs , allows users select , cancel selected jobs.

we trying follow restful approach our api, that's gets confusing.

getting jobs easy - simple get: /jobs

how shall cancel selected jobs? bearing in mind operation on jobs need implement. easiest , logical approach (to me) send list of selected jobs ids api (server) , necessary procedures. that's not restful way.

if following restful approach seams need send patch request jobs, json similar this:

patch: /jobs [     {       "op": "replace",       "path": "/jobs/123",       "status": "cancelled"     },     {       "op": "replace",       "path": "/jobs/321",       "status": "cancelled"     }, ] 

that require generating json on client, mapping model on server, parsing "path" property job id , actual cancellation. seems convoluted , artificial me.

what general advice on kind of operation? i'm curious people in real life when lot of operations can't mapped restful resource paradigm.

thanks!

if cancelling job mean deleting use delete verb:

delete /jobs?ids=123,321,... 

if cancelling job mean setting status field cancelled use patch verb:

patch /jobs content-type: application/json [ { "id": 123, "status": "cancelled" }, { "id": 321, "status": "cancelled" } ] 

Comments

Popular posts from this blog

angular - Is it possible to get native element for formControl? -

unity3d - Rotate an object to face an opposite direction -

javascript - Why jQuery Select box change event is now working? -