api - JSON request to create entity with existent inner object -
i develop rest api , think following task. need post vehicle entity , bind existing driver it. common approach format json such request? choose 1 of these variants, maybe there better solutions:
1. {"model":"corolla","number":"12345", "driver": {"id": 5}} 2. {"model":"corolla","number":"12345", "driver": {"id": 5, "name": "john"}} 3. {"model":"corolla","number":"12345", "driverid": 5}
the question how pass information created driver entity known id.
according jsonapi, format :
{ "model":"corolla", "number":"12345" "links": { "driver": "5" } }
conventions defined in website may usefull you.
Comments
Post a Comment