About Inspecting Webhook Data While Developing

You can check the test data posted to a webhook using Sentry.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
from django.http import HttpResponse
from django.views.decorators.csrf import csrf_exempt
import sentry_sdk

@csrf_exempt
def webhook(request):
    if request.method == "POST":
        post_dict = request.POST.dict()
        sentry_sdk.set_context("Post Data", post_dict)
        sentry_sdk.capture_message("Webhook Triggered")
    return HttpResponse("OK")

For security reasons, it's not recommendable to do that with sensitive data like credit card numbers or other secrets.

Tips and Tricks Programming Django 5.x Django 4.2 Django 3.2 Sentry