[PR #4263] [MERGED] Closes #4237: Enable custom templating for webhook request content #12804

Closed
opened 2025-12-29 22:23:42 +01:00 by adam · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/netbox-community/netbox/pull/4263
Author: @jeremystretch
Created: 2/24/2020
Status: Merged
Merged: 2/25/2020
Merged by: @jeremystretch

Base: developHead: 4237-custom-webhooks


📝 Commits (7)

📊 Changes

10 files changed (+230 additions, -95 deletions)

View changed files

📝 docs/additional-features/webhooks.md (+55 -43)
📝 docs/release-notes/version-2.7.md (+1 -0)
📝 netbox/extras/admin.py (+25 -3)
📝 netbox/extras/choices.py (+11 -10)
📝 netbox/extras/constants.py (+2 -0)
netbox/extras/migrations/0038_webhook_template_support.py (+48 -0)
📝 netbox/extras/models.py (+48 -21)
📝 netbox/extras/tests/test_webhooks.py (+1 -1)
📝 netbox/extras/webhooks.py (+0 -1)
📝 netbox/extras/webhooks_worker.py (+39 -16)

📄 Description

Fixes: #4237

  • Change the http_content_type field from a choice field to a free-form string. This allows the user to specify an arbitrary content type.
  • Add the body_template field for defining a Jinja2 template.
  • Enable logging for the webhooks worker

Screenshot_2020-02-24 Change webhook NetBox

The above configuration will generate a request similar to what follows:

127.0.0.1 - - [24/Feb/2020 15:55:24] "POST / HTTP/1.1" 200 -
------------
Host: localhost:9000
Accept-Encoding: identity
Content-Type: application/json
Content-Length: 34

Someone created a site named Foo!

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/netbox-community/netbox/pull/4263 **Author:** [@jeremystretch](https://github.com/jeremystretch) **Created:** 2/24/2020 **Status:** ✅ Merged **Merged:** 2/25/2020 **Merged by:** [@jeremystretch](https://github.com/jeremystretch) **Base:** `develop` ← **Head:** `4237-custom-webhooks` --- ### 📝 Commits (7) - [`99038ff`](https://github.com/netbox-community/netbox/commit/99038ffc44d9e0c12fb801ea102fdb22581e1041) Enable custom templating for webhook request content - [`1fbd3a2`](https://github.com/netbox-community/netbox/commit/1fbd3a2c265935e55a28061328daede616f72c5a) Convert additional_headers to a TextField - [`9a532b1`](https://github.com/netbox-community/netbox/commit/9a532b1eb274760940bda574b7cc8343b0510dd7) Extend templatization ability to additional_headers field - [`211311b`](https://github.com/netbox-community/netbox/commit/211311be9f37add9b77ad73968ca22be900949f0) Add http_method field to Webhook - [`644b4aa`](https://github.com/netbox-community/netbox/commit/644b4aa42d4177772b9ee800f143f945e15f6504) Revised webhook documentation - [`c3b6416`](https://github.com/netbox-community/netbox/commit/c3b64164bad070161eb9d2ee29114db73c962bec) Always use a JSON object to convey change data when no body template is present - [`3578696`](https://github.com/netbox-community/netbox/commit/35786966c618b14f9f525ed5834aa04354223695) Changelog for #4237 ### 📊 Changes **10 files changed** (+230 additions, -95 deletions) <details> <summary>View changed files</summary> 📝 `docs/additional-features/webhooks.md` (+55 -43) 📝 `docs/release-notes/version-2.7.md` (+1 -0) 📝 `netbox/extras/admin.py` (+25 -3) 📝 `netbox/extras/choices.py` (+11 -10) 📝 `netbox/extras/constants.py` (+2 -0) ➕ `netbox/extras/migrations/0038_webhook_template_support.py` (+48 -0) 📝 `netbox/extras/models.py` (+48 -21) 📝 `netbox/extras/tests/test_webhooks.py` (+1 -1) 📝 `netbox/extras/webhooks.py` (+0 -1) 📝 `netbox/extras/webhooks_worker.py` (+39 -16) </details> ### 📄 Description # Fixes: #4237 - Change the `http_content_type` field from a choice field to a free-form string. This allows the user to specify an arbitrary content type. - Add the `body_template` field for defining a Jinja2 template. - Enable logging for the webhooks worker ![Screenshot_2020-02-24 Change webhook NetBox](https://user-images.githubusercontent.com/13487278/75191762-f9d0c480-5720-11ea-83f7-2089cd127cf7.png) The above configuration will generate a request similar to what follows: ``` 127.0.0.1 - - [24/Feb/2020 15:55:24] "POST / HTTP/1.1" 200 - ------------ Host: localhost:9000 Accept-Encoding: identity Content-Type: application/json Content-Length: 34 Someone created a site named Foo! ``` --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
adam added the pull-request label 2025-12-29 22:23:42 +01:00
adam closed this issue 2025-12-29 22:23:42 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#12804