Thursday, May 28, 2015

Django post response method post not allowed

Hello,

I am trying to post a request via curl. 

curl -H  "Authorization: Bearer $usertoken" -X POST -d '{"username":"foo1","object":"XYZ","prefs":"likes"}' http://${endpoint}/setProfile/


Here is the entry in my urls.py

url(r'^setProfile/', AddToUserProfile),

class AddToUserProfile(generics.ListAPIView):
queryset = UserPrefs.objects.all()
serializer_class = UserPrefSerializer

class UserPrefSerializer(serializers.ModelSerializer):
class Meta:
model = UserPrefs
fields = ('id', 'prefs', 'obj_id', 'user_id')
depth = 1

I get a response - {"detail":"Method \"POST\" not allowed."}

Is there anything else I need to specify?

- Shekar

--
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+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/d8db1691-e60d-4a46-9598-47227bd4c6e9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment