# 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