I have been working with the Twitch API for some time now and have made a API-V5 Java handler for handling any requests between my bot and the Twitch API.
However, when i do a request for subscribers using the endpoint: /channels/[CHANNEL_ID]/subscriptions
Instead of getting back something that makes sense, like a proper error message… I’m getting random rubbish, anyone have any ideas?
Hm. I don’t see your error printing in your screenshot. Your System.out.println has the string “Error (” in it, and the error in your screenshot is "Error: " with no parentheses, status code, etc.
Sorry about that… it was prior to me adding the ("+statusCode+") section.
Sometimes when I boot the bot it returns the proper response:
Error (403): {“error”:“Forbidden”,“status”:403,“message”:“The current authorization is not valid for this context”}
Other times it returns gibberish, even when I haven’t changed any source code.
The highlighted section of the screenshot above shows the error message
Could it be responding with GZIP encoded content? I mean it shouldn’t do that unless you tell it to in the Accept-Encoding header, but that’s what I think of when I hear “gibberish”.
Well as I said, the API may send a GZIP encoded response, even if it shouldn’t. I encountered APIs like that before. In fact, I am receiving a response on the /kraken/channels/<id>/subscriptions endpoint which contains a Content-Encoding: gzip, even if I don’t send an Accept-Encoding header. I can’t test if the content is actually GZIP encoded since I don’t have access to a partnered channel. On other Twitch API endpoints (the ones I happen to use at least) it seems fine.