On Friday, 16 October 2015 15:24:21 UTC+1, Sabine Maennel wrote: > > Hello, > > I tried to followed this Tutorial from Go Django, but I do not get it to > work. Can you please help me on how to react on a webhook in my application. > > *This is the tutorial,* that I tried to follow: > https://godjango.com/55-webhooks-django-and-ngrok/ > > *This is my view:* > > # coding: utf-8 > > from __future__ import unicode_literals, absolute_import > > import json > > from django.views.generic import View > > from braces.views import CsrfExemptMixin > > import logging > logger = logging.getLogger(__name__) > > class ProcessHookView(CsrfExemptMixin, View): > def post(self, request, args, *kwargs): > print(json.loads(request.body)) > return HttpResponse() > > > *url file: * > > # -*- coding: utf-8 -*- > > from __future__ import unicode_literals > > from django.conf.urls import patterns, include, url > from .providers.hook import ProcessHookView, test_view, my_webhook_view > > > urlpatterns = patterns('', > > url(r'^test$', > ProcessHookView.as_view()), > > ) > > > > The view does not work: I tried to call it with: > > curl -X POST http://127.0.0.1:8000/de/webhooks/x -d '{"foo": "bar"}' > > > and get this error: > > *[16/Oct/2015 16:09:57] "POST /de/webhooks/test HTTP/1.1" 500 112859* > > > if I try the url directly I get this error: > > *[16/Oct/2015 16:10:20] "GET /de/webhooks/test HTTP/1.1" 405 0* > > > What am I doing wrong? Is there an example on how to do it right? Do I > need Celery for this? > > Any help is highly appreciated > > with kind regards > > Sabine Maennel > >
Looks like the post you are following had a formatting problem, maybe thanks to conversion from Markdown. The signature of the `post` method should be: def post(self, request, *args, **kwargs): ie one asterisk before args, and two for kwargs. Celery has nothing to do with this sort of thing - it's for offline processing. You might well want to trigger a Celery task from your webhook receiver, especially if the sender is expecting a quick response, but it's not required. -- DR. -- 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 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/2b9c16d9-3f27-4f7f-bffd-d3db6fdfb2c9%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.