This project has moved and is read-only. For the latest updates, please go here.

JsonException Invalid token '34' ....

Aug 9, 2012 at 10:59 AM

Hi Joe,

Have you had any chance in resolving this issue ? I am getting this error from time to time (not always).

I also tried to download your last commit but I can't build it for WinRT..

Thanks in advance



Aug 9, 2012 at 3:37 PM

Hi Nick,

I believe there's a current issue in Twitter where it doesn't return a complete response in Search queries.  Are you doing a Search query?  What type of query are you doing?

This error is typical for that type of problem because the Json parser doesn't have a complete object.  If you get into a place where you can reproduce this, try to run Fiddler to look at the response and see if the last Json object is complete.  I've done some work in this area to block the read of the Http stream to get a complete response, but I'm wondering if there's an edge case that I'm not covering.  Any sample that you have to reproduce would be helpful.  It's possible that this might also be related to an issue that Twitter is working on, but it might be good for me to take a look in case it's reproducible and I might be able to do something about it.

In the meantime, a workaround might be to capture the exception and re-try the query to see if you get a full response the next time.


Aug 10, 2012 at 7:12 AM

Hi Joe,

Thanks for the quick reply.

Yes, it happens (sometimes) when doing a search query.

var tweets = (from tweet in twitterCtx.Search
                              where tweet.Type == SearchType.Search &&
                                    tweet.Query == hashtag &&
                                    tweet.Hashtag == hashtag.Remove(0, 1) &&
                                    tweet.PageSize == 25
                              select tweet.Results).ToList();

I will hook up Fiddler to see if I can get more information.

Thanks for the current workaround.



Aug 10, 2012 at 4:45 PM
Edited Aug 10, 2012 at 4:45 PM

Hi guys,

I'm also getting a JSON exception and I wonder if it's related.

Input doesn't evaluate to proper JSON text.

Basically i'm monitoring a specific Twitter account every 5 mins to see if any new tweets have been posted.

The exception occurs only occasionally while the parameters are unchanged. (same twitter account, same query).

Do you have an idea whether this is a similar problem Joe or should I open a separate topic for this?


Aug 17, 2012 at 5:13 PM


It sounds like it's related.  I'd take the same approach and wrap the response in a try/catch to retry.


Aug 17, 2012 at 10:19 PM

I got this when I was unable to reach Twitter, my router was powered off inadvertently.


Aug 23, 2012 at 3:08 PM
JoeMayo wrote:


In the meantime, a workaround might be to capture the exception and re-try the query to see if you get a full response the next time.



This workaround seems to be working for me for the time being, on a single retry. Do you recommend retrying a certain number of times?
Do you have an idea when a fix for this issue should be available? Is there a tracker?

Thanks Joe!


Aug 23, 2012 at 6:14 PM


Generally, it's good to schedule a few retries, with a backoff strategy that sleeps the thread to keep you from hitting the server too many times at once and/or affecting your rate limit.

I'm seeing other people with incomplete response postings on Twitter's discussion forum: If you're seeing incomplete responses in Fiddler, it might be useful to contribute to one of the discussions there.