vendredi 14 mai 2021

RESTful service. Different response and request schema

My understanding of REST is that a resource endpoint should expose the same schema, irrespective of the HTTP VERB. E.g. the same JSON schema is used for:

PUT /foo/
GET /foo/{id}
POST /foo/{id}

How do I handle fields that should only be populated by the server. E.g. created_on, created_by, id.

Should I use separate schema per endpoint? Do nothing and ignore the created_on value if it's sent by the client? Return an error if the client tries to send created_on?

Aucun commentaire:

Enregistrer un commentaire