Skip to content

Add support for custom headers in webhook API

  • Please check this box if this contribution uses AI-generated content (including content generated by GitLab Duo features) as outlined in the GitLab DCO & CLA

What does this MR do and why?

Add support for custom headers in webhook API

Relates to Support for custom webhook headers in the API (#455528)

MR acceptance checklist

Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Screenshots or screen recordings

API only changes

How to set up and validate locally

  1. Create a project hook using the API
    {
      "url": "some-url",
      "custom_headers": [{ "key": "some-key", "value": "some-value" }]
    }
  2. Open the UI and check that a hook with a some-key header has been set, test the webhook and see if the value is passed correctly
  3. Edit the hook using the API
    { "custom_headers": [{ "key": "some-other-key", "value": "some-value" }] }
    Now, the hook should have both some-key and some-other-key custom headers.
  4. Use the set custom header endpoint: PUT /projects/:id/hooks/:hook_id/custom_headers/some-key
    { "value": "some-new-value" }
    Test the hook again and verify that the new value is sent in the header
  5. Delete a custom header: DELETE /projects/:id/hooks/:hook_id/custom_headers/some-key. You can check in the UI that the custom header was removed.
  6. Repeat these steps for groups (if you have an active license)
Edited by Niklas van Schrick

Merge request reports