How to Cancel a REST api request?

First, support

POST /requests

which will return a reference to the status of the request

{
    "id": 1234,
    "self"": "/requests/1234"
    "status": "Running"
}

Then add support for

PUT /requests/1234
{
    "status": "Canceled:"
}

That will let clients cancel a request if it hasn't finished yet. If the request is to create some other kind of resource, then instead of POST /requests, do POST /myResource, but still return the status object with the pointer to /requests in the response.

Clients can then poll /requests to see when the request is complete.

Tags:

Java

Rest