0

I have a set of resources:

[{
"name": "process-1",
"id": "1",
"state": "active"
},...
]

I get them by GET service-name/version/processes?state=running&sort=by_date

I need to update the set: update state in existing processes and get new running processes. How should I design this API according to RESTful best practice?

Is it a good solution to design it by the following way:

POST service-name/version/processes?action=refresh

body: {ids: ["1", "2", "3", ...]}

or should I implement refresh as external resource-operation?

UPDATE:

I don't want to update objects on server side, I just want to refresh them on client side

Sergei Podlipaev
  • 1,331
  • 1
  • 14
  • 34
  • Possible duplicate of [How to Update a REST Resource Collection](https://stackoverflow.com/questions/28638071/how-to-update-a-rest-resource-collection), also see [REST: Updating Multiple Resources With One Request - Is it standard or to be avoided?](https://stackoverflow.com/questions/32098423/rest-updating-multiple-resources-with-one-request-is-it-standard-or-to-be-avo). In short, RESTful APIs should not contain verbs, `action=refresh` would qualify as a verb. The recommended HTTP verb for updating a collection is `PATCH`, I'd definitely read the answers on the other posts though. – James Aug 08 '18 at 10:27
  • @James Well, I don't want to update anything, I just want to refresh objects on client-side – Sergei Podlipaev Aug 08 '18 at 10:55
  • 1
    At no point in your *original* question did you mention that, *"I need to update the set: update state in existing processes and get new running processes"* and *"How should I design this API"* would elude to this being a server-side question. – James Aug 08 '18 at 11:28

1 Answers1

1

If this is a strictly client-side problem, you don't need any new HTTP endpoints. You just do the same GET request again.

Evert
  • 93,428
  • 18
  • 118
  • 189