0

For a RESTful API, consider a model schema as follows:

MyCoolObject {
  field_a
  field_b
  field_c
}

Is it better to create one update endpoint to update one or many fields on the model? Or create one endpoint per field that would only update that one field?

4
  • Is there some reason why someone would want to update this object one field at a time? That just sounds bizarre to me.
    – John Wu
    Jan 13 at 20:54
  • @JohnWu, one field at a time is an exaggerration, but in a scenario where your model is very large and you wanted to minimize over-the-wire costs, requests containing the whole object could get expensive Jan 14 at 5:22
  • Maybe it would be a better idea to avoid very large models.
    – John Wu
    Jan 14 at 8:23
  • Easier said than done hahaha Jan 14 at 17:02
1

There is no one answer for this question. It really depends on how the underlying object changes, what kind of business rules or process you have around the change, etc etc etc.

1

One option would be to use the same endpoint, but use HTTP PUT to update the entire model and use PATCH to update one or more individual fields.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.