Azure Function Not Receiving JSON Body from JIRA Webhook

I’m having trouble with my JIRA webhook and Azure Function setup. The webhook works fine when I test it with a request bin, but when I point it to my Azure Function, something weird happens.

The Function receives the request, but the JSON body is empty. Also, the headers look different from what I see in the request bin.

Here’s what I’ve noticed:

  1. Request bin gets the full JSON payload and expected headers.
  2. Azure Function gets an empty body and different headers.
  3. When I use Postman to send a payload to the Azure Function, it works perfectly.

I’m scratching my head trying to figure out why Azure isn’t getting the JSON from JIRA when other tools have no problem. Has anyone run into this before? Any ideas on what might be causing this or how to fix it?

# Example of how I'm trying to handle the webhook in Azure Function
import azure.functions as func

def main(req: func.HttpRequest) -> func.HttpResponse:
    try:
        req_body = req.get_json()
        issue_key = req_body['issue']['key']
        return func.HttpResponse(f'Received issue: {issue_key}')
    except ValueError:
        return func.HttpResponse('No JSON body found', status_code=400)

Any help would be really appreciated!

I’ve dealt with this exact problem before, and it’s frustrating. One thing to check is your Function’s authorization level. If it’s set to ‘function’ or ‘admin’, JIRA might not be able to authenticate properly, causing the body to be stripped. Try changing it to ‘anonymous’ temporarily to test.

Also, double-check your Function’s bindings. Make sure you have an HTTP trigger with the correct methods (POST, usually). Sometimes the default template doesn’t include all necessary settings.

Lastly, consider adding some logging in your Function to see exactly what’s coming in. You might spot something unexpected in the raw request that gives you a clue. If all else fails, you could try using a different trigger type, like a Queue trigger, with an HTTP-triggered Function acting as a proxy to pass the data along.

I encountered a similar issue when setting up a JIRA webhook with Azure Functions. The problem was related to how Azure Functions handles certain incoming requests. Here’s what worked for me:

First, I modified my function to explicitly parse the raw body instead of relying on the built-in JSON parsing. This approach catches cases where the content type might be mismatched.

import json

def main(req: func.HttpRequest) -> func.HttpResponse:
    body = req.get_body().decode('utf-8')
    try:
        req_body = json.loads(body)
        issue_key = req_body['issue']['key']
        return func.HttpResponse(f'Received issue: {issue_key}')
    except json.JSONDecodeError:
        return func.HttpResponse('Invalid JSON body', status_code=400)
    except KeyError:
        return func.HttpResponse('Missing required fields', status_code=400)

Additionally, I had to adjust the JIRA webhook configuration to ensure it was sending the correct content type. In the JIRA webhook settings, I explicitly set the ‘Content Type’ to ‘application/json’.

These changes resolved the issue for me. Hope this helps!

hey olivias, that’s a tricky one! i’ve had similar issues before. have u checked if jira is using a different content-type header when sending to azure? sometimes it defaults to application/x-www-form-urlencoded instead of application/json. try parsing the body as form data and see if that helps. good luck!