调用Streamlabs API发送测试警报遭遇405错误求助
Hey there! That HTTP 405 error you're seeing means the server doesn't allow the request method you're using—and that's exactly the issue here.
核心问题:请求方法不匹配
The send_test_alert endpoint from Streamlabs API requires a GET request, not POST. Both of your attempts use requests.post(), which is why the server rejects them with a 405 "Method Not Allowed" error.
修正后的代码示例
Switch to requests.get() and your request should work. Here are the corrected versions of your two approaches:
方法1:用params传递参数(更推荐,符合规范)
import requests url = "https://streamlabs.com/api/alerts/send_test_alert" params = { "access_token": "UserAccessTokenHere", "type": "donation" } response = requests.get(url=url, params=params) print(response.text)
方法2:直接在URL中拼接参数
import requests url = "https://streamlabs.com/api/alerts/send_test_alert?access_token=UserAccessTokenHere&type=donation" response = requests.get(url=url) print(response.text)
额外确认
You already have the correct alerts.write scope in your OAuth permissions, so that part is set up perfectly—no issues there. Just swapping the request method from POST to GET should get your test alert working as expected.
内容的提问来源于stack exchange,提问作者HelloThereToad

