[Answer]-Django tastypie returning 401 always for POST method and works well for GET

1đź‘Ť

From tastypie tutorial:
http://django-tastypie.readthedocs.org/en/latest/tutorial.html#hooking-up-the-resource-s

However, if you try sending a POST/PUT/DELETE to the resource, you
find yourself getting “401 Unauthorized” errors. For safety, Tastypie
ships with the authorization class (“what are you allowed to do”) set
to ReadOnlyAuthorization. This makes it safe to expose on the web, but
prevents us from doing POST/PUT/DELETE. Let’s enable those:

authorization = Authorization()

But you specified this as Authorization =, it’s wrong.
And, how it is mentioned in tutorial, POST and etc. without authentication is insecure.

👤coldmind

Leave a comment