C
C#3y ago
bookuha

Correct POST and PATCH

POST 1️⃣ For example, I have an Entity Book{name, [5 fields related solely to book], authorEntityId} Should I post only this Book related information and add my authorId later, or include it into the initial request? Or should I allow making partial POSTs (is this a thing?), so you can populate it fully, or partially, but I feel it is not OK /// PATCH 2️⃣ I've noticed some "command+data patch json notation" People send something like:
{
do/change/modify: "name",
data: "CLR via C#"
}
{
do/change/modify: "name",
data: "CLR via C#"
}
Do you like it? What are the drawbacks? Should I match the name and send specific command based on the match? ("name" => _mediatr.Send(new ChangeNameCommand(request.data) is the way?) /// 3️⃣ Also, what I noticed, is that it also may be done for entire specific verb system, like
{
do: "delete-author-entirely",
data : "Buddy Eric"
}
{
do: "delete-author-entirely",
data : "Buddy Eric"
}
this will remove author from the system entirely, and lets say, we want to expose this functionality to our frontend client-moderators Is this a correct way to do this? Is it RESTful for you?
1 Reply
Mayor McCheese
See https://jsonpatch.com/ for the standard. It’s very useful in some scenarios where you need high audibility, field level permissions, etc.
jsonpatch.com
JSON Patch
Website for jsonpatch.com, with general info about JSONPatch

Did you find this page helpful?