Confluence webhooks events do not include charset=utf-8 in the header

XMLWordPrintable

    • Severity 3 - Minor

      Issue Summary

      Confluence webhooks do not include charset=utf-8 encoding with the Content-Type: header, which causes errors during payload parsing. A standard Spring Boot application fails with the following error.

      JSON parse error: Invalid UTF-8 start byte 0xfc]
      

      The same webhook listener client works fine for Jira webhooks, which by default include the header Content-Type: application/json; charset=utf-8

      Steps to Reproduce

      1. Create a Spring Boot application and implement
        @RestController
        public class WebhookController {
            @PostMapping(value="/webhook")
            public ResponseEntity<String> listenToWebhook(@RequestBody JsonNode requestBody) {
                // Log the incoming webhook payload for debugging
                System.out.println("Received webhook payload: " + requestBody.toString());
            }
        }
        
      2. Run the Spring Boot application
      3. Create a webhook using the rest API /rest/webhooks/1.0/webhook
        {
          "name": "Confluence_Webhook_test",
          "url": "https://<your service domainname>/webhook",
          "events": [
            "page_removed",
            "page_trashed"
          ]
        } 
        
      4. Create a page with the title "test ü".
      5. Delete the page.

      Expected Results

      The webhook events include the correct Content-Type: header, including the charset.

      Content-Type: application/json; charset=UTF-8
      

      Actual Results

      The webhook events do not include the correct Content-Type: header, including the charset.

      Content-Type: application/json
      

      Workaround

      Create a Custom Filter:

      • Implement the javax.servlet.Filter interface.
      • Override the doFilter method to intercept incoming requests.
      • Inside the doFilter method:
        • Access the request character encoding using request.getCharacterEncoding().
        • If it's null or not UTF-8, set the encoding to UTF-8 using request.setCharacterEncoding("UTF-8").

            Assignee:
            Unassigned
            Reporter:
            Deepak Pandey
            Votes:
            26 Vote for this issue
            Watchers:
            12 Start watching this issue

              Created:
              Updated:
              Resolved: