Hey there,
i got some problems by getting the UserID “GET https://api.twitch.tv/kraken/users?login=username” with C# on api v5.
Other requests for channel/channelname or something like that works great, but on user?login i got
the status 404 back.
For the moment i do it like that.
on my Dll file:
public TwitchReadOnlyClient(string clientID, string url = TwitchHelper.twitchApiUrl)
{
restClient = new RestClient(url); // url = “https://api.twitch.tv/kraken”
restClient.AddHandler(“application/json”, new DynamicJsonDeserializer());
restClient.AddHandler(“text/html”, new DynamicJsonDeserializer());
restClient.AddDefaultHeader(“Accept”, TwitchHelper.twitchAcceptHeader); // “application/vnd.twitchtv.v5+json”;
restClient.AddDefaultHeader(“Client-ID”, clientID);
}
public Users GetUser(string username)
{
var request = GetRequest("users?login={username}", Method.GET);
request.AddUrlSegment("username", username);
var response = restClient.Execute<Users>(request);
return response.Data;
}
on my main programm:
private static string userName = "xxxxx";
private static string password = "oauth:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
private static string channel = "xxxxxxxx";
private static string TwitchClientID = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
private static string oauthKey = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
TwitchReadOnlyClient TwitchROClient = new TwitchReadOnlyClient(TwitchClientID);
// to test call funktion by button click
private void button1_Click(object sender, EventArgs e)
{
var myUser = TwitchAuthClient.GetUser(userName); /// <<< probem dont give me response error 404
var IDChannel = TwitchROClient.GetChannel(channel); // works fine for the moment with the ChannelName. With ID there will be the same 404 status
}