Provided hub.topic doesn't work

So at the moment, I’m trying to figure out what in the world I’m doing so I can eventually write better code for this, so forgive me if it’s a mess.

(All python btw)

I’m trying to subscribe to follow events from user_id 51375532 so I’m using the endpoint
api_endpnt = "https://api.twitch.tv/helix/webhooks/hub?hub.callback=mycallback&hub.mode=subscribe&hub.lease_seconds=600&hub.topic=https://api.twitch.tv/helix/users/follows?first=1&to_id=51375532"

(The callback is fine on my end I just didn’t know if that’s something I should censor)

head = {
'Client-ID': 'myid',
"Authorization": "mytoken"

}

And then I’m eventually making the request withr = requests.post(url=api_endpnt, headers=head)

But then I get a hub.topic unsupported topic. The only thing not copied and pasted in hub.topic is my id. I’m assuming this has to do with the way the endpoint is being parsed because other ones work (like subscribing to a channels updates) but since there’s an ampersand it’s having problems?

Sorry again if this is a mess I’m new and have looked around for an answer to this for 2 hours now. Thanks!

You’re sending the webhook parameters wrong, they should be sent as JSON in the request body, not in the querystring.

https://dev.twitch.tv/docs/api/webhooks-reference

1 Like

Thank you so much! I did

    data_raw = {
        "hub.callback" : "mycallback",
        "hub.mode" : "subscribe",
        "hub.lease_seconds" : "600",
        "hub.topic" : "https://api.twitch.tv/helix/users/follows?first=1&to_id=549320051"
    }

and it finally worked! I didn’t know I was supposed to be using JSON this whole time. Thanks!

Edit: For other python users submit the request using
r = requests.post(url=api_endpnt, data=data_raw, headers=head)

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.