Skip to content

Instantly share code, notes, and snippets.

@PVince81
Last active July 30, 2023 16:05
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save PVince81/6fce6662d5d37387a8a4c48328f25403 to your computer and use it in GitHub Desktop.
Save PVince81/6fce6662d5d37387a8a4c48328f25403 to your computer and use it in GitHub Desktop.
Webdav vs REST
Operation Webdav REST
Create collection
  • predefined id: `MKCOL /entities/$predefined_id`
  • no predefined id: not possible
  • can set attributes right away with extended-mkcol extension
  • Status: 201 Created
  • `POST /entities` with JSON body with attributes, response contains new id
  • Status: 200 with new id and optionally the whole object
Create entity
  • predefined id: `PUT /entities/$predefined_id` with body, empty response
  • no predefined id: `POST /entities`, receive id as part of Content-Location header
  • can't set attributes right away, need subsequent PROPPATCH
  • Status: 201 Created
Update entity body
  • `PUT /entities/$predefined_id` with new body (no attributes)
  • Status: 204 No Content
  • Full: `PUT /entities/$id` with full JSON body with attributes
  • Status 200, receive full object back
  • Partial: `PATCH /entities/$id` with partial JSON containing only attributes to update.
  • Status 200, full/partial object returned
Update entity attributes
  • `PROPPATCH /entities/$id` with XML body of attributes to change
  • Status: 207, XML body with accepted attributes
Delete entity
  • `DELETE /entities/$id`
  • Sattus: 204 no content
List entities
  • `PROPFIND /entities` with XML body of attributes to fetch
  • Status 207 multi-status XML response with multiple entities and their respective attributes
  • `GET /entities`
  • Status: 200 OK, receive JSON response array with JSON body of entity attributes
Get entity
  • `GET /entities/$id`
  • Status: 200 OK with entitiy body
  • `GET /entities/$id`
  • Status 200 OK, receive JSON body of entity attributes
Get entity attributes
  • `PROPFIND /entities/$id` with XML body of attributes to fetch
  • Status 207 multi-status XML response with entity attributes
Notes
  • cannot always set attributes right away at creation time, need subsequent `PROPPATCH`
  • no concept of body vs attributes
  • entity can be either collection or model (for collection `/entities/$collectionId/$itemId`)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment