1

I am trying to add members in a list using Linq To Twitter API. According to the documentation I can add 100 members per request and can add upto 5000 members. https://dev.twitter.com/docs/api/1.1/post/lists/members/create_all

With that, I wrote a little function

public static async Task<List> AddMembersToList(ulong twitterUserId, ulong listId, List<ulong> followerIds, SingleUserAuthorizer auth)
{
    var twitterContext = new TwitterContext(auth);
    try
    {
        int count = 0;
        while (followerIds.Count > count)
        {
            await twitterContext.AddMemberRangeToListAsync(listId, null, twitterUserId, null, followerIds.Skip(count).Take(100).ToList());
            count += 100;
        }
        return new List();
    }

    catch (Exception ex)
    {
        return null;
    }
}

The above should suppose to work but I am getting two different errors.. Sometime, I am getting an error message

Over Capacity

And sometime, it throws an error

ex = {"<!DOCTYPE html>\n<html xmlns=\"http://www.w3.org/1999/xhtml\" lang=\"en\" xml:lang=\"en\">\n  <head>\n    <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">\n    <meta http-equiv=\"Content-Language\" content=\"en-us\">\n    <meta name...

I am not able to figure out the reason..I need your suggestion

Ammar Khan
  • 2,565
  • 6
  • 35
  • 60
  • I am not sure, if you already saw this example. http://linqtotwitter.codeplex.com/wikipage?title=Adding%20Multiple%20Members%20to%20a%20List – Vladimir Gondarev Mar 09 '14 at 16:26
  • Yeah, I already saw this example. That was a simple example for adding only two members. I want to add 100 members per iteration and upto 5000 members in a list. Not sure, why it throws an error with the above code. – Ammar Khan Mar 09 '14 at 16:29
  • At the moment, I cannot test the code you provided. But I suggest you to try it less than 100 items, for instance, 50 members and so on. will see whether it will work. – Vladimir Gondarev Mar 09 '14 at 16:36
  • I already tried that out sir, unfortunately that's not work either. I test that adding upto 20 members per iteration but after couple of iteration, it fails. – Ammar Khan Mar 09 '14 at 16:43
  • I need more information about the errors you're getting. What does the ToString of the TwitterQueryException say? Is there a StatusCode and ErrorCode. – Joe Mayo Mar 21 '14 at 01:29

0 Answers0