Closed tomtjes closed 1 year ago
Existing objects will require an ID. (also, I believe keywords:[{}]
is invalid - either omit it entirely or just drop the internal {})
You can probably get away with just an ID, or maybe ID and name.
Thanks. Just tried that, but adding id fields doesn't help. Also played around with different versions of keyword arrays. The template json from the API browser doesn't include id fields and according to the API doc, the name fields are required.
{
"title": "",
"recipe": {
"name": "",
"description": "",
"keywords": [],
"working_time": null,
"waiting_time": null,
"internal": false,
"servings": null,
"servings_text": "",
"rating": null,
"last_cooked": null
},
"servings": null,
"note": "",
"date": null,
"meal_type": {
"name": "",
"order": null,
"icon": "",
"color": "",
"default": false
},
"shared": []
}
The following minimal API worked
curl -X POST 127.0.0.1:8000/api/meal-plan/ -H 'Content-Type: application/json' -H 'Authorization: Bearer tda_xxxxxxxxxxxxxxxxxxxxxxxxxxxxx' -d '{"recipe": {"id": 100, "name": "recipe", "keywords": []}, "meal_type": {"id": 1, "name": "test type"}, "date": "2023-09-06", "servings": 1, "title": "Test Meal Plan", "shared": []}'
This works for me as well. Thank you so much for checking!
Not sure if we should close this issue or if the API documentation and API browser template json need fixing, since there's no mention of the id field there.
This works for me as well. Thank you so much for checking!
Not sure if we should close this issue or if the API documentation and API browser template json need fixing, since there's no mention of the id field there.
The documentation is automatically generated - for better or worse the 'create' assumes creation of the nested objects as well.
Tandoor Version
commit d42d784aeb0595bbc0ed47eb8bbc27ba61b0787d
Setup
Docker / Docker-Compose
Reverse Proxy
SWAG
Other
No response
Bug description
I'm trying to create meal plan entries via API. I'm sending a POST request to
.../api/meal-plan/
with the following JSON:The recipe "test recipe" and meal type "any" exist.
Relevant logs