[Helix] Get Videos, Following Cursor Returns 400 - Bad Request After 600 Results

Bug

When requesting videos via game_id and following the cursor to get all results, 400 - Bad Request is returned when offset is internally set to 600 by Twitch. This behavior was observed across any game_id that was supplied, with any other combination of optional query parameters.

This bug was only limited to querying videos by game_id. Querying videos by user_id worked perfectly regardless of the number of videos returned.

Request

  • Endpoint: /videos
  • Method: GET
  • Parameters: game_id=493057, first=100, after=eyJiIjp7Ik9mZnNldCI6NDAwfSwiYSI6eyJPZmZzZXQiOjYwMH19

Test #1 - Following the Cursor

[TestMethod]
public void
GetVideosAsync_Parameters_GameID()
{
    HelixRequestSettings settings = GetTestSettings();

    // TODO: Look up by game name
    VideosParameters paramerters = new VideosParameters();
    paramerters.game_id = GameCache.list[0].id;
    paramerters.first = 100;

    // BUG: (Twitch) When following the cursor to request all videos via game_id, '400 - Bad Request' is returned when offset is internally set to 600 by Twitch.
    //      This behavior is only observed when providing a game_id and when there are only more than 600 results.
    //      Folliwng the cursor when requesting via user_id works perfectly, no matter how many results are returned.
    IHelixResponse<DataPage<Video>> response_1 = TwitchApi.OAuth.GetVideosAsync(RokuHodo.bearer_token, paramerters, settings).Result;
    Assert.AreEqual(HttpStatusCode.OK, response_1.status_code);
    Assert.IsTrue(response_1.result.data.Count > 100);
    Assert.IsNull(response_1.exception);
}

The first six requests in the test above were executed with no errors and getting back the expected 600 video results. After following the cursor, eyJiIjp7Ik9mZnNldCI6NDAwfSwiYSI6eyJPZmZzZXQiOjYwMH19, to request the next page, 400 - Bad Request was returned.

Test #2 - Requesting the Page Specifically

[TestMethod]
public void
GetVideosPageAsync_Parameters_GameID()
{
    HelixRequestSettings settings = GetTestSettings();

    // TODO: Look up by game name
    VideosParameters paramerters = new VideosParameters();
    paramerters.game_id = GameCache.list[0].id;
    paramerters.after = "eyJiIjp7Ik9mZnNldCI6NDAwfSwiYSI6eyJPZmZzZXQiOjYwMH19";
    paramerters.first = 100;

    IHelixResponse<DataPage<Video>> response_1 = TwitchApi.OAuth.GetVideosPageAsync(RokuHodo.bearer_token, paramerters, settings).Result;
    Assert.AreEqual(HttpStatusCode.OK, response_1.status_code);
    Assert.AreEqual(100, response_1.result.data.Count);
    Assert.IsNull(response_1.exception);
}

The same error 400 - Bad Request was returned when explicitly requesting the cursor.

Error Message

In both tests above, the following error was returned by Twitch:

This seems like an error message that was never intended to be returned to the end user since we don’t have direct access to offset in Helix like we did in Kraken. As a side note, the message is a serialized string instead of a plane message like in every other endpoint error message I’ve encountered thus far.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.