Custom verbs or operations in REST API
- 1 minutes read - 174 wordsStandard REST API has limited verbs if using http verbs. However in reality and many business contexts, they are not enough. In the past, many options are proposed. Today I found another option in FHIR. It might be helful to put them here for comparison.
Control data in request
In stackoverflow What to do when you need more verbs in REST, cheeso gave the answer below. It is like the way json-rpc, not well-specified version. it is not in the style consistent with other verbs.
{ actions: [ {action:"modify", data: {...} }, { action:"approve"} ] }
Verb or opertions at the end of resource endpoints: prefix verbs with $
POST http://fhir.someserver.org/fhir/Patient/1/$everything
Examples: . fhir
Verb or opertions at the end of resource path, seperated with resource id by colon
POST https://service.name/v1/some/resource/name:customVerb
google gives the reason to use : instead of / to separate the custom verb from the resource name is to support arbitrary paths. It has a good point.