I’m sending a POST
request to my endpoint like this:
curl -X POST https://directus.myapp.com/items/recipes \
-H "Authorization: Bearer MY_TOKEN" \
-d '{
"name": "My Recipe"
}'
I get a 200 OK response, but the data I sent doesn’t seem to be saved—I’m just getting the default values back every time. Any idea what could be causing this?
I realized I need to include the Content-Type: application/json
header in my request. Without it, Directus doesn’t know I’m sending JSON, so it just treats the body as empty.
Here’s the corrected curl
command:
curl -X POST https://directus.myapp.com/items/recipes \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"name": "My Recipe"
}'
That fixed it! Now my data gets processed and saved properly.