REST: Using path parameters, query parameters or JSON for multiple obligatory fields

8 Views Asked by At

I'm creating a route where I have to disable an object and inform the reason of a predetermined list of reasons. It is not an option to have an empty reason (see, null reason)

So, I started asking myself which would be the best practice:

  • /{object-id}/{reason-id}/
  • /{object-id}?reason-id=
  • {object-id}/ with a JSON body consisting of
{
"reason-id": int
}
  • /disable/ with a JSON body consisting of
{
"object-id": int,
"reason-id": int
}

Maybe I am overthinking, but I'd find strange to have an obligatory query parameter or having two path parameters which aren't related to each other in one-to-many or one-to-one fields. If having a reason was optional, then I'd think about using query parameters, but inn this case I just don't know

0

There are 0 best solutions below