I'm trying to move a resource from /buckets/1
to /buckets/2
such that:
What's a RESTful way of asking the server to move a resource in this manner?
REST API POST Example To send data to the REST API server, you must make an HTTP POST request and include the POST data in the request's body. You also need to provide the Content-Type: application/json and Content-Length request headers. Below is an example of a REST API POST request to a ReqBin REST API endpoint.
Resource Path (request target)The path to the resource (object) to be acted upon. The ID of the resource must be provided in the path. For example, the following resource path identifies a specific transaction (resource) in our database: Copy. https://apitest.cybersource.com/pts/v2/payments/
Resources are the basic building block of a RESTful service. Examples of a resource from an online book store application include a book, an order from a store, and a collection of users. Resources are addressable by URLs and HTTP methods can perform operations on resources.
Access to the direct management API Management REST API must be granted before calls can be successfully made. Navigate to your Azure API Management instance in the Azure portal. Select Management API from the Deployment + infrastructure section of the menu on the left. In Enable API Management REST API, select Yes.
Answering my own question:
/balls
GET /buckets/1
returning the value of the ball in the bucket let's have it return the URI of the ball instead.We can then move balls as follows:
(examine original state)
GET /buckets/1: "balls = {'/balls/1'}"
GET /buckets/2: "balls = {}"
GET /balls/1: "bucket = /buckets/1"
(move ball into bucket #2)
PUT /balls/1: "bucket = /buckets/2"
(examine new state)
GET /buckets/1: "balls = {}"
GET /buckets/2: "balls = {'/balls/1'}"
GET /balls/1: "bucket = /buckets/2"
End-result: the ball's identity remains consistent as it moves across buckets and (most importantly) this operation is atomic.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With