That is an odd error to get, however you didn’t JSON encode your data parameters, you just posted as a form.
The hub expects a JSON blob to be posted, or the parameters passed as query string arguments (undocumented). You did neither and sent as post data.
So you didn’t tell the hub to do anything!
Also I’m assuming that TWITCH_API_ENDPOINT is https://api.twitch.tv/helix/webhooks/hub
When testing your logic (posting as a form), I get
{
"error": "Bad Request",
"status": 400,
"message": "Must provide a valid Content-Type header with a request body. Please use application/json or application/x-www-form-urlencoded"
}
As I was expecting, so you need to Post as query string or JSON blob, not multipart
So you got a completely unexpected error, and your hook creation code is incorrect.