Search code examples
c#twitterlinq-to-twitter

Getting Error Accessing Twitter Data While Using LinqToTwitter


I'm using this code to get name from screen name of twitter users:

    var users =
        (from user in twitterCtx.User
         where user.Type == UserType.Lookup &&
               user.ScreenName == "JoeMayo,LinqToTweeter"
         select user)
         .ToList();

    users.ForEach(user => Console.WriteLine("Name: " + user.Name));

but I received this error message:

System.AggregateException: One or more errors occurred. —-> System.ArgumentException: Query must contain one of either ScreenNameList or UserIdList parameters, but not both.

How can resolve this problem ?


Solution

  • You're close - all you need to do is replace user.ScreenName with user.ScreenNameList, like this:

    var users =
        (from user in twitterCtx.User
         where user.Type == UserType.Lookup &&
               user.ScreenNameList == "JoeMayo,LinqToTweeter"
         select user)
        .ToList();
    
    users.ForEach(user => Console.WriteLine("Name: " + user.Name));
    

    You can find a running Demo in the source code. There's documentation available too.