A
A
Andrey Prozorov2018-03-19 14:17:44
RESTful API
Andrey Prozorov, 2018-03-19 14:17:44

How to correctly save related data Principles of REST api?

Option 1.
PUT server.com/location/656
body:

{
  name: '',
  status: 1,
  manager: {
    id: 546
 }
}

and as a result, I expect that the manager will be linked to this location and its properties will be updated
Option 2.
PUT server.com/location/656
body:
{
  name: '',
  status: 1,
  manager: {
    name: 'Вася'
 }
}

and as a result, I expect that a manager will be created and it will link to this location, and its properties will be updated.
How true is this? is it worth splitting this action into two actions perhaps?
PS do not scold too much in these matters, I'm new.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question