Home > Blockchain >  Inventory REST API
Inventory REST API

Time:09-16

I have a REST API with a resource "computers".

Every minute, each computer sends a GET request to "/computers/computer_id" I would like to store the last time each computer communicated with the API.

My first thought was to add a field "last_communicated" to the "computers" resource, and update it whenever a computer GETs itself from the API.

But, having a GET request modify the resource it gets doesn't sit well with me.

Is there a better solution to this ?

CodePudding user response:

Ultimately most GET requests are going to make changes to the server. For example, most servers have an access log so technically doing a GET request alters the server state.

I this this becomes more problematic if that last_communicated is also returned from that GET response body. If you do, I would suggest you just use a more appropriate HTTP method like POST.

  • Related