golf1052 / Twixel

Unofficial C# Twitch.TV API Wrapper
http://golf1052.github.io/Twixel/
MIT License
11 stars 6 forks source link

JsonReaderException: Unexpected character encountered while parsing value: <. Path '', line 0, position 0. #9

Closed ibiza240 closed 8 years ago

ibiza240 commented 9 years ago

Hello,

let me say first that this API is great, I've been using it with success so far!

I encountered a surprising error while doing a simple query :

var twixel = new TwixelAPI.Twixel("abc123xyz", "");
var result = await twixel.RetrieveStreams(channels: listOfChannels);

got me a

Newtonsoft.Json.JsonReaderException: Unexpected character encountered while parsing value: <. Path '', line 0, position 0.
   at Newtonsoft.Json.JsonTextReader.ParseValue()
   at Newtonsoft.Json.JsonTextReader.ReadInternal()
   at Newtonsoft.Json.JsonTextReader.Read()
   at Newtonsoft.Json.Linq.JObject.Load(JsonReader reader)
   at Newtonsoft.Json.Linq.JObject.Parse(String json)
   at TwixelAPI.Twixel.<DoWebData>d__a5.MoveNext()
--- End of stack trace from previous location where exception was thrown ---

Unfortunately I don't know what was the content of listOfChannels at the time of the crash, but I am positive that it was a normal list of channels (streamers names)

Since I am not able to find the cause and fix it, I thought maybe you would make more sense of it than me.

golf1052 commented 9 years ago

I created a branch and test for this issue: 5ff714896135e03176b243ed6cac121c5b764832

I'm not seeing it come up on my end but I think it's an issue I actually fixed recently (but haven't put up on NuGet yet). Basically sometimes Twitch sucks and doesn't send back a normal Twitch error response but instead sends an HTML error response. In this commit (5adb1c66187bdd988ac1641694ffa290c8f0476c) I catch and throw an appropriate exception for the error.

ibiza240 commented 9 years ago

Thanks for replying! I would gladly try the new version, but the commit link doesn't seem to be working

golf1052 commented 9 years ago

Just pushed the latest source to NuGet: https://www.nuget.org/packages/Twixel/2.0.4

golf1052 commented 9 years ago

Also fixed the commit link.

ibiza240 commented 9 years ago

Thanks! Will try and let you know :)

ibiza240 commented 8 years ago

It looks like you fixed it. Thanks!