Hi Soumen,
On 04/02/2020 12.14, Soumen Khatua wrote:
curl -i -X POST -H "Authorization: Basic Nzc5NzcyNzU0MDpzb3VtZW4xMjM="
http://127.0.0.1:8000/job_post/ --data '{"job_description":"Python
Developers"}'
Here I'm passing the data of job_description but still I'm getting an
error like:
*
*
*HTTP/1.1 400 Bad Request
Date: Tue, 04 Feb 2020 11:12:05 GMT
Server: WSGIServer/0.2 CPython/3.8.1
Content-Type: application/json
Vary: Accept
Allow: GET, POST, PUT, DELETE, HEAD, OPTIONS
X-Frame-Options: SAMEORIGIN
Content-Length: 47
{"job_description":["This field is required."]}*
Could you tell me why I'm getting this error?
but in POSTMAN it is woking properly.
That's impossible to answer without seeing your actual code, but a few
hints:
You are not setting the content type when posting. Try setting that to
JSON. It could be the error message that is just confusing and it's not
trying to parse the input as JSON, but you should not that better if you
wrote the code.
The payload you are posting definitely looks like JSON, but I have no
idea which structure your code is expecting.
It can often be useful to sniff the traffic to see what is actually
being sending when debugging stuff like this. A tool like wireshark is
extremely useful for that:
https://www.wireshark.org/
Happy debugging,
Kasper Laudrup
--
You received this message because you are subscribed to the Google Groups "Django
users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/71ae3f30-cba1-a275-1cd0-7155063be0ab%40stacktrace.dk.