I tried to create a java Tool to change Twitch Channel Informations (status / game / delay). In the Documentation is an example with curl for working with the API to update channel informations:
curl -H 'Accept: application/vnd.twitchtv.v3+json' -H 'Authorization: OAuth <access_token>' \
-d "channel[status]=Playing+cool+new+game!&channel[game]=Diablo&channel[delay]=0" \
-X PUT https://api.twitch.tv/kraken/channels/test_channel
I tried to recreate this in Java with HttpsURLConnection. But I get the Error Response Code 400 and I dont have any idea what could be wrong with my sourcecode.
The Response:{"error":"Bad Request","message":"Missing required parameter channel","status":400}
My sourcecode: http://pastebin.com/F1QyCULu
I hope anyone can help me with this problem.
Okay I found a way how it works.
I removed the URLEncoder and just replaced spaces with plus String sendData = "channel[" + key + "]=" + data.replace(' ', '+');
I set the content-type to application/x-www-form-urlencoded apiConnection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
and thats it.