Exception when getting rate limit status

Oct 11, 2012 at 7:37 AM

Corresponding this http://linqtotwitter.codeplex.com/wikipage?title=Getting%20Rate%20Limit%20Status I tryed to get rate limet status but all the time i have this exception:

"InvalidOperationException:The default case of BuildUrl should never execute because a Type must be specified."

here is code i used (copied from documentation: Documentation Go Making API Calls Go Managing Accounts Go Getting Rate Limit Status )

 

var accounts =
                from acct in twitterCtx.Account
                where acct.Type == AccountType.RateLimitStatus
                select acct;
            foreach (var account in accounts)
            {
                var hits = account.RateLimitStatus.RemainingHits;
                      ...
            }

I have installed linq to twitter via nuget (version is 2.1.0.1).
Examples works fine but they use earlier version (about 2.0.8)
I haven't this problem with version of used in examples (version 2.0.8)

Can you help me, how can I wolk around this exception, thanks.

Coordinator
Oct 11, 2012 at 1:07 PM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.
Coordinator
Oct 11, 2012 at 1:13 PM

Hi,

This particular call has been replaced and moved to the help entity when I upgraded to Twitter API v1.1. Twitter recently changed their Rate Limit policies to one that has separate rate limits for each API.  Here's what you can do now:

            var helpResult =
                (from help in twitterCtx.Help
                 where help.Type == HelpType.RateLimits //&&
                       //help.Resources == "search,users"
                 select help)
                .SingleOrDefault();

            foreach (var category in helpResult.RateLimits)
            {
                Console.WriteLine("\nCategory: {0}", category.Key);

                foreach (var limit in category.Value)
                {
                    Console.WriteLine(
                        "\n  Resource: {0}\n    Remaining: {1}\n    Reset: {2}\n    Limit: {3}",
                        limit.Resource, limit.Remaining, limit.Reset, limit.Limit);
                }
            }
Joe

 

Oct 14, 2012 at 12:58 AM

Are you going to keep us informed of updates are do we need to check back from time to time?

From: JoeMayo [email removed]
Sent: Thursday, October 11, 2012 7:14 AM
To: erik@builderbits.com
Subject: Re: Exception when getting rate limit status [LinqToTwitter:398916]

From: JoeMayo

Hi,

This particular call has been replaced and moved to the help entity when I upgraded to Twitter API v1.1. Twitter recently changed their Rate Limit policies to one that has separate rate limits for each API. Here's what you can do now:

            var helpResult =
                (from help in twitterCtx.Help
                 where help.Type == HelpType.RateLimits //&&
                       //help.Resources == "search,users"
                 select help)
                .SingleOrDefault();
 
            foreach (var category in helpResult.RateLimits)
            {
                Console.WriteLine("\nCategory: {0}", category.Key);
 
                foreach (var limit in category.Value)
                {
                    Console.WriteLine(
                        "\n  Resource: {0}\n    Remaining: {1}\n    Reset: {2}\n    Limit: {3}",
                        limit.Resource, limit.Remaining, limit.Reset, limit.Limit);
                }
            }
Joe

Coordinator
Oct 14, 2012 at 2:21 AM

Twitter updating to v1.1 was pretty significant, so I tweeted different things about it. i.e. retweeting @twitterapi, tweeting a couple times running up to the event, and then tweeting the release.  I followed up with a blog post at http://geekswithblogs.net/WinAZ/archive/2012/09/21/converting-linq-to-twitter-to-twitter-api-v1.1.aspx, and also posted to this forum at http://linqtotwitter.codeplex.com/discussions/396404.

I'll normally Tweet a release, so if you're following me on Twitter, you'll get notified right away. Looking at Source | History, http://linqtotwitter.codeplex.com/SourceControl/list/changesets, you can see every change I've made since my initial check-in in September 2008. In particular, the changes associated with a particular release are highlighted, so you always know what I did.

I've updated to Twitter v1.1 pretty quick, within days in fact, of them announcing it's availability.  My gut feeling is that a few more things will change.  Of course Twitter is continuously changing the API in one way or another, so the task of keeping LINQ to Twitter up-to-date is never boring. I still have to update existing samples and do another pass over the documentation, but after that, things should start slowing down again.

Follow me on Twitter at @JoeMayo and you'll know when I do a release.

Joe