Skip to main content
replaced http://stackoverflow.com/ with https://stackoverflow.com/
Source Link
URL Rewriter Bot
URL Rewriter Bot

Thanks Cassio for emphasizing the 'changing the object state' approach.

My own answer for completeness:

PATCH /resources/{resourceId} with body {"active":false} -- deactivate a resource PATCH /resources/{resourceId} with body {"active":true} -- restore a resource GET /resources -- return all 'normal' resources GET /resources?includeInactive=true -- return all resources including the deactivated ones GET /resources/{resourceId} -- return the resource 

(The resources retrieved by 'GET' will contain the attribute 'active=true/false').

Seems like a classic case for PATCH: When I should use PATCH or PUT in my REST API request and Design?When I should use PATCH or PUT in my REST API request and Design?

Thanks Cassio for emphasizing the 'changing the object state' approach.

My own answer for completeness:

PATCH /resources/{resourceId} with body {"active":false} -- deactivate a resource PATCH /resources/{resourceId} with body {"active":true} -- restore a resource GET /resources -- return all 'normal' resources GET /resources?includeInactive=true -- return all resources including the deactivated ones GET /resources/{resourceId} -- return the resource 

(The resources retrieved by 'GET' will contain the attribute 'active=true/false').

Seems like a classic case for PATCH: When I should use PATCH or PUT in my REST API request and Design?

Thanks Cassio for emphasizing the 'changing the object state' approach.

My own answer for completeness:

PATCH /resources/{resourceId} with body {"active":false} -- deactivate a resource PATCH /resources/{resourceId} with body {"active":true} -- restore a resource GET /resources -- return all 'normal' resources GET /resources?includeInactive=true -- return all resources including the deactivated ones GET /resources/{resourceId} -- return the resource 

(The resources retrieved by 'GET' will contain the attribute 'active=true/false').

Seems like a classic case for PATCH: When I should use PATCH or PUT in my REST API request and Design?

added 82 characters in body
Source Link
Alexander
  • 2.9k
  • 1
  • 33
  • 40

Thanks Cassio for emphasizing the 'changing the object state' approach.

My own answer for completeness:

PATCH /resources/{resourceId} with body {"active":false} -- deactivate a resource PATCH /resources/{resourceId} with body {"active":true} -- restore a resource GET /resources -- return all 'normal' resources GET /resources?includeInactive=true -- return all resources including the deactivated ones GET /resources/{resourceId} -- return the resource 

(The resources retrieved by 'GET' will contain the attribute 'active=true/false').

Seems like a classic case for PATCH: When I should use PATCH or PUT in my REST API request and Design?

Thanks Cassio for emphasizing the 'changing the object state' approach.

My own answer for completeness:

PATCH /resources/{resourceId} with body {"active":false} -- deactivate a resource PATCH /resources/{resourceId} with body {"active":true} -- restore a resource GET /resources -- return all 'normal' resources GET /resources?includeInactive=true -- return all resources including the deactivated ones GET /resources/{resourceId} -- return the resource 

(The resources retrieved by 'GET' will contain the attribute 'active=true/false').

Thanks Cassio for emphasizing the 'changing the object state' approach.

My own answer for completeness:

PATCH /resources/{resourceId} with body {"active":false} -- deactivate a resource PATCH /resources/{resourceId} with body {"active":true} -- restore a resource GET /resources -- return all 'normal' resources GET /resources?includeInactive=true -- return all resources including the deactivated ones GET /resources/{resourceId} -- return the resource 

(The resources retrieved by 'GET' will contain the attribute 'active=true/false').

Seems like a classic case for PATCH: When I should use PATCH or PUT in my REST API request and Design?

deleted 297 characters in body
Source Link
Alexander
  • 2.9k
  • 1
  • 33
  • 40

Thanks Cassio for emphasizing the 'changing the object state' approach.

My own answer for completeness:

POST or PATCH /resources/{resourceId}/hidden with body {"active":false}  -- deactivate a resource DELETEPATCH /resources/{resourceId}/hidden with body {"active":true}  -- restore a resource GET /resources -- return all 'normal' resources GET /resources?hidden=true includeInactive=true -- return all resources including the deactivated resourcesones GET /resources/{resourceId} -- return the resource 

(The resources retrieved by 'GET' will contain the attribute 'hidden=true'active=true/false').

That is, conceptually there is a boolean object (the 'hidden' flag) on top of the 'resource', that can be either created or deleted and whose presence changes the nature of the 'resource', i.e. a resource with this flag present ceases to be a 'normal' one.

Similar approach in GitHub: https://developer.github.com/v3/gists/#star-a-gist

Thanks Cassio for emphasizing the 'changing the object state' approach.

My own answer for completeness:

POST or PATCH /resources/{resourceId}/hidden -- deactivate a resource DELETE /resources/{resourceId}/hidden -- restore a resource GET /resources -- return all 'normal' resources GET /resources?hidden=true  -- return all deactivated resources GET /resources/{resourceId} -- return the resource 

(The resources retrieved by 'GET' will contain the attribute 'hidden=true/false').

That is, conceptually there is a boolean object (the 'hidden' flag) on top of the 'resource', that can be either created or deleted and whose presence changes the nature of the 'resource', i.e. a resource with this flag present ceases to be a 'normal' one.

Similar approach in GitHub: https://developer.github.com/v3/gists/#star-a-gist

Thanks Cassio for emphasizing the 'changing the object state' approach.

My own answer for completeness:

PATCH /resources/{resourceId} with body {"active":false}  -- deactivate a resource PATCH /resources/{resourceId} with body {"active":true}  -- restore a resource GET /resources -- return all 'normal' resources GET /resources?includeInactive=true -- return all resources including the deactivated ones GET /resources/{resourceId} -- return the resource 

(The resources retrieved by 'GET' will contain the attribute 'active=true/false').

added 5 characters in body
Source Link
Alexander
  • 2.9k
  • 1
  • 33
  • 40
Loading
deleted 213 characters in body
Source Link
Alexander
  • 2.9k
  • 1
  • 33
  • 40
Loading
added 50 characters in body
Source Link
Alexander
  • 2.9k
  • 1
  • 33
  • 40
Loading
Source Link
Alexander
  • 2.9k
  • 1
  • 33
  • 40
Loading