From 6210ded1eafbaa0fcbac1e54672bd9ba7000e5bc Mon Sep 17 00:00:00 2001 From: Jeremy Stretch Date: Fri, 20 Mar 2026 14:56:17 -0400 Subject: [PATCH] Closes #21702: Include originating HTTP request in outbound webhook context data --- netbox/extras/tests/test_event_rules.py | 3 +++ netbox/extras/webhooks.py | 7 +++++++ 2 files changed, 10 insertions(+) diff --git a/netbox/extras/tests/test_event_rules.py b/netbox/extras/tests/test_event_rules.py index b6abf4c85..4f9aec74f 100644 --- a/netbox/extras/tests/test_event_rules.py +++ b/netbox/extras/tests/test_event_rules.py @@ -370,6 +370,9 @@ class EventRuleTest(APITestCase): self.assertEqual(body['data']['name'], 'Site 1') self.assertEqual(body['data']['foo'], 1) self.assertEqual(body['context']['foo'], 123) # From netbox.tests.dummy_plugin + self.assertEqual(body['request']['id'], str(request_id)) + self.assertEqual(body['request']['method'], 'GET') + self.assertEqual(body['request']['user'], 'testuser') return HttpResponse() diff --git a/netbox/extras/webhooks.py b/netbox/extras/webhooks.py index e30fe976e..0a68216ea 100644 --- a/netbox/extras/webhooks.py +++ b/netbox/extras/webhooks.py @@ -57,6 +57,13 @@ def send_webhook(event_rule, object_type, event_type, data, timestamp, username, 'request_id': request.id if request else None, 'data': data, } + if request: + context['request'] = { + 'id': str(request.id) if request.id else None, + 'method': request.method, + 'path': request.path, + 'user': str(request.user), + } if snapshots: context.update({ 'snapshots': snapshots