I thought I had the API fairly well figured out at this stage, but I’m finding adding quantities to logs a little troublesome. From the documentation I see the quantity should be created first and the the log created with a relationship referencing the quantity UUID.
So I can create the quantities with no issue, but when I create the log and add the relationship using either POST or PATCH after the fact, the relationship is not saved, I get no errors and receive status code 201. All other details in the POST request are saved OK too.
eg:
POST
{"type":"log--transplanting","attributes":{"data":"2022-W17 Zucchini HVW11-N","status":"done","notes":{"value":"Length (m): 16; Nr of plants: 20"},"flag":[],"is_movement":true},"relationships":{"location":{"data":[{"type":"asset--land","id":"be022fa6-fbfb-4557-aff7-ffab7503914d"}]},"asset":{"data":[{"type":"asset--plant","id":"df263fee-d226-42b3-804f-15d33ef866a3"}]},"quantity":{"data":[{"type":"quantity--standard","id":"56227855-36b9-4a77-a37e-7cd8cb6ad636"},{"type":"quantity--standard","id":"d14cbabc-9f25-4c18-a584-9dd8409a7ed8"}]}}}
Returns
{"type":"log--transplanting","id":"0d4bc521-0960-47e4-bfb6-7b759c900685","links":{"self":{"href":"http://192.168.1.34/api/log/transplanting/0d4bc521-0960-47e4-bfb6-7b759c900685"}},"attributes":{"drupal_internal__id":61,"drupal_internal__revision_id":128,"langcode":"en","revision_created":"2022-05-08T11:21:36+00:00","revision_log_message":null,"name":"Transplanting log 61","timestamp":"2022-05-08T11:21:36+00:00","status":"done","created":"2022-05-08T11:21:36+00:00","changed":"2022-05-08T11:21:36+00:00","default_langcode":true,"revision_translation_affected":true,"data":"2022-W17 Zucchini HVW11-N","notes":{"value":"Length (m): 16; Nr of plants: 20","format":null,"processed":"<p>Length (m): 16; Nr of plants: 20</p>\n"},"flag":[],"is_group_assignment":null,"geometry":null,"is_movement":true},"relationships":{"log_type":{"data":{"type":"log_type--log_type","id":"20e6447d-c7c1-449b-b0c1-e47cb0293975","meta":{"drupal_internal__target_id":"transplanting"}},"links":{"related":{"href":"http://192.168.1.34/api/log/transplanting/0d4bc521-0960-47e4-bfb6-7b759c900685/log_type"},"self":{"href":"http://192.168.1.34/api/log/transplanting/0d4bc521-0960-47e4-bfb6-7b759c900685/relationships/log_type"}}},"revision_user":{"data":{"type":"user--user","id":"8fd752ad-31de-4141-a541-4338322b9f94","meta":{"drupal_internal__target_id":1}},"links":{"related":{"href":"http://192.168.1.34/api/log/transplanting/0d4bc521-0960-47e4-bfb6-7b759c900685/revision_user"},"self":{"href":"http://192.168.1.34/api/log/transplanting/0d4bc521-0960-47e4-bfb6-7b759c900685/relationships/revision_user"}}},"uid":{"data":{"type":"user--user","id":"8fd752ad-31de-4141-a541-4338322b9f94","meta":{"drupal_internal__target_id":1}},"links":{"related":{"href":"http://192.168.1.34/api/log/transplanting/0d4bc521-0960-47e4-bfb6-7b759c900685/uid"},"self":{"href":"http://192.168.1.34/api/log/transplanting/0d4bc521-0960-47e4-bfb6-7b759c900685/relationships/uid"}}},"category":{"data":[],"links":{"related":{"href":"http://192.168.1.34/api/log/transplanting/0d4bc521-0960-47e4-bfb6-7b759c900685/category"},"self":{"href":"http://192.168.1.34/api/log/transplanting/0d4bc521-0960-47e4-bfb6-7b759c900685/relationships/category"}}},"file":{"data":[],"links":{"related":{"href":"http://192.168.1.34/api/log/transplanting/0d4bc521-0960-47e4-bfb6-7b759c900685/file"},"self":{"href":"http://192.168.1.34/api/log/transplanting/0d4bc521-0960-47e4-bfb6-7b759c900685/relationships/file"}}},"image":{"data":[],"links":{"related":{"href":"http://192.168.1.34/api/log/transplanting/0d4bc521-0960-47e4-bfb6-7b759c900685/image"},"self":{"href":"http://192.168.1.34/api/log/transplanting/0d4bc521-0960-47e4-bfb6-7b759c900685/relationships/image"}}},"group":{"data":[],"links":{"related":{"href":"http://192.168.1.34/api/log/transplanting/0d4bc521-0960-47e4-bfb6-7b759c900685/group"},"self":{"href":"http://192.168.1.34/api/log/transplanting/0d4bc521-0960-47e4-bfb6-7b759c900685/relationships/group"}}},"location":{"data":[{"type":"asset--land","id":"be022fa6-fbfb-4557-aff7-ffab7503914d","meta":{"drupal_internal__target_id":28}}],"links":{"related":{"href":"http://192.168.1.34/api/log/transplanting/0d4bc521-0960-47e4-bfb6-7b759c900685/location"},"self":{"href":"http://192.168.1.34/api/log/transplanting/0d4bc521-0960-47e4-bfb6-7b759c900685/relationships/location"}}},"asset":{"data":[{"type":"asset--plant","id":"df263fee-d226-42b3-804f-15d33ef866a3","meta":{"drupal_internal__target_id":33}}],"links":{"related":{"href":"http://192.168.1.34/api/log/transplanting/0d4bc521-0960-47e4-bfb6-7b759c900685/asset"},"self":{"href":"http://192.168.1.34/api/log/transplanting/0d4bc521-0960-47e4-bfb6-7b759c900685/relationships/asset"}}},"quantity":{"data":[],"links":{"related":{"href":"http://192.168.1.34/api/log/transplanting/0d4bc521-0960-47e4-bfb6-7b759c900685/quantity"},"self":{"href":"http://192.168.1.34/api/log/transplanting/0d4bc521-0960-47e4-bfb6-7b759c900685/relationships/quantity"}}},"owner":{"data":[{"type":"user--user","id":"8fd752ad-31de-4141-a541-4338322b9f94","meta":{"drupal_internal__target_id":1}}],"links":{"related":{"href":"http://192.168.1.34/api/log/transplanting/0d4bc521-0960-47e4-bfb6-7b759c900685/owner"},"self":{"href":"http://192.168.1.34/api/log/transplanting/0d4bc521-0960-47e4-bfb6-7b759c900685/relationships/owner"}}},"equipment":{"data":[],"links":{"related":{"href":"http://192.168.1.34/api/log/transplanting/0d4bc521-0960-47e4-bfb6-7b759c900685/equipment"},"self":{"href":"http://192.168.1.34/api/log/transplanting/0d4bc521-0960-47e4-bfb6-7b759c900685/relationships/equipment"}}}}}
I’m sure I’m missing something relatively simple.