Search code examples
linq-to-twitter

search fails with maxid (ulong.max) and sinceid set, but separately it works


the following query works ok if you comment out either the SinceID or the MaxID clause, but when both are included a "bad url" exception is generated.

var maxId = ulong.MaxValue;
var sinceId = (ulong)341350918903701507;

var searchResult =
(
   from search in ctx.Search
      where search.Type == SearchType.Search &&
      search.ResultType == ResultType.Mixed &&
      search.Query == "red wedding" &&
      search.SinceID == sinceId &&
      search.MaxID == maxId &&
      search.IncludeEntities == false &&
      search.Count == 200
    select search).SingleOrDefault();

Solution

  • If you look at the query result in Fiddler, you'll see that the response is:

    {"errors":[{"code":195,"message":"Missing or invalid url parameter"}]}
    

    I can't respond to why Twitter wouldn't accept the query with both SinceID and MaxID. However, the query is formed correctly and there isn't any documentation describing constraints on the relationship between these two parameters for this particular scenario. The purpose of the MaxID is to be the id of the highest tweet to return on the next query. Both MaxID and SinceID are intended to help you page through data. I wrote a blog post on how to do this:

    Working with Timelines with LINQ to Twitter