I assume you are using Django REST Framework.
ListAPIViews only accepts GET requests, because well, it's supposed only to list stuff. If you need to add data, try the CreateAPIView, or depending on what you want, a ListCreateAPIView.
On Thu, May 28, 2015 at 10:58 AM, Shekar Tippur <ctippur@gmail.com> wrote:
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.pyurl(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.
| Filipe Ximenes +55 (81) 8245-9204 Vinta Software Studio http://www.vinta.com.br |
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/CAA-QWB3Zkc8%2BuVFcA8oD5M_9SAKMv6QAKboPGyUY2C2pBQn%3DwA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment