I am developing in C# utilizing the Azure environment. I have used Postman to help determine proper requests and everything I have appears to be working as expected but when I check the webhooks/subscriptions for what I’ve signed up for… it is empty. Any guidance is appreciated.
My request to subscribe to the user stream event:
POST /helix/webhooks/hub?hub.callback=https://XXXXXX.azurewebsites.net/api/TwitchStreamChange&hub.mode=subscribe&hub.topic=https://api.twitch.tv/helix/streams?user_id=433XXXXXX2&hub.lease_seconds=864000&hub.secret=0XXXXXXXXXXXXXXXXXXXr9g HTTP/1.1
Host: api.twitch.tv
Content-Type: application/json
Authorization: Bearer lpXXXXXXXXXXXXXXXmu
I receive the 202 Accepted response. I then receive an HttpRequest with the hub.challenge:
Request Received
Length: ‘No Length’
Type: ‘No Type’
Has Cookies: ‘0’
Has Headers: ‘16’
Method: ‘GET’
Scheme: ‘https’
Route: ‘0’
QueryString: ‘?hub.challenge=__k2XXXXXXXXXXXXXKh5aikw&hub.lease_seconds=864000&hub.mode=subscribe&hub.topic=https%3A%2F%2Fapi.twitch.tv%2Fhelix%2Fstreams%3Fuser_id%3D43XXXXXX2’
Body: ‘’
I send the pingback and get the following response:
If I try a “live” user the data payload is populated. The user in the example just happens to be offline…
When I check for the webhook I get an empty payload.
{
“total”: 0,
“data”: ,
“pagination”: {}
}
Everything appears to be working per the ‘New Twitch API’ Webhooks Guide and Reference. Is there anything I am missing or can try to get my Stream Event subscription to stick?
I am sending the following and get back the top 20 live and the pagination. If I provide the user_id as a querystring parameter it will return just the streamer payload if they are live or an empty one if they are not. Should I send the user_id or does that not matter?
GET /helix/streams?hub.challenge=MIFpXXXXgCwGiFBatkS7 HTTP/1.1
Host: api.twitch.tv
Content-Type: text/plain
Authorization: Bearer lp1XXXXay8epmu
The GET in my second post is from Postman… The challenge code is sent as a query string as @Dist suggested. C# is the same format.
It should be noted that I receive the payload after I send the challenge back. I’m assuming, of course, that the payload means the api received the challenge successfully.
When Twitch sends a GET request to your callback URL, containing a hub.challenge, your server needs to respond to that request from Twitch by returning the hub.challenge in the body.
You don’t send it as a querystring on anything, you don’t need to make any more requests yourself, you simply respond to Twitch’s GET request to you with the challenge in the body. If Twitch doesn’t get back JUST the hub.challenge and a 200 response when it sends a GET request to your callback URL, it assumes either the callback url isn’t accessible, or isn’t set up to handle webhooks, and so the subscription process fails.