UserStream.StartStream (400) Bad Request

Aug 4, 2014 at 10:37 AM
Hi,
Using version 0.9.
I am having problems starting the UserStream, when I call UserStream.StartStream ( even calling UserStream.StartStreamAsynch is the same) I always receive a StreamStopped event. The credentials should be right since the "rateLimits" info is shown properly.
The exception is:
USERSTREAM ERROR: System.Net.WebException: The remote server returned an error: (400) Bad Request.
   at System.Net.HttpWebRequest.EndGetResponse(IAsyncResult asyncResult)
   at System.Threading.Tasks.TaskFactory`1.FromAsyncCoreLogic(IAsyncResult iar, Func`2 endFunction, Action`1 endAction, Task`1 promise, Boolean requiresSynchronization)
Any ideas?
Here it is the code:
   var credentials = TwitterCredentials.CreateCredentials(token, secretToken,  ConsumerKey,  ConsumerSecret);
                TwitterCredentials.ExecuteOperationWithCredentials(credentials, () =>
                {
                    this.UserStream = Stream.CreateUserStream();

                    var rateLimits = RateLimit.GetCurrentCredentialsRateLimits();
                    Console.WriteLine("You can access your timeline {0} times.", rateLimits.StatusesHomeTimelineLimit.Remaining);

                    UserStream.TweetCreatedByMe += (s, a) => { NotifyMyTweet(a); };
                    UserStream.TweetCreatedByFriend += (s, a) => { NotifyFriendTweet(a); };
                    UserStream.MessageReceived += (s, a) => { NotifyMessageTweet(a); };
                    UserStream.StreamStopped += (s, a) =>
                    {
                        Console.WriteLine("USERSTREAM ERROR: " + a.Exception.ToString());
                    };
                    UserStream.StreamRunning += (s, a) => { Console.WriteLine("USERSTREAM RUNNING"); };
                    UserStream.StreamResumed += (s, a) => { Console.WriteLine("USERSTREAM RESUMED"); };

                    UserStream.StartStream(); 
                });
Thanks,
Andrea
Aug 4, 2014 at 10:51 AM
I finally found the problem:

Instead of calling the:
TwitterCredentials.ExecuteOperationWithCredentials
I had to call the:
TwitterCredentials.ApplicationCredentials = TwitterCredentials.CreateCredentials(token, secretToken, ConsumerKey, ConsumerSecret);
That solved my problem.

Thanks for such a useful API!
Marked as answer by anbrandi on 8/4/2014 at 2:51 AM