5👍
✅
DRF needs the Content-Type
header to find the correct parser for your data.
Try to add -H "Content-Type:application/json"
to your curl-call.
Also note single-quotes ('
)as you use them aren’t valid JSON. JSON only allows double-quotes ("
).
So your correct curl-call would be
curl -X POST http://127.0.0.1:8000/email/new/ -H "Content-Type: application/json" -d '{"sender": "a@b", "receiver":"c@d", "message":"yolo"}'
Source:stackexchange.com