Henry-Sarabia / igdb

Go client for the Internet Game Database API
https://api.igdb.com/
MIT License
81 stars 17 forks source link

Unable to Filter by Name for GameVideos #106

Open HammerMeetNail opened 3 years ago

HammerMeetNail commented 3 years ago

There might be an issue filtering by non-id fields for GameVideos.Index().

Querying the IGDB API https://api.igdb.com/v4/game_videos directly with the following body yields a single item.

Body:

fields name,video_id;
where id = 48965;
limit 500;
offset 0;

Response:

[
    {
        "id": 48965,
        "name": "Announcement Trailer",
        "video_id": "61-OMrOxyso"
    }
]

Querying by name instead of id yields a response with multiple items:

Body:

fields name,video_id;
where name = ("Announcement Trailer");
limit 500;
offset 0;

When using this library, filtering by ID works but not by Name. Works:

options := igdb.ComposeOptions(
        igdb.SetLimit(500),
        igdb.SetOffset(0),
        igdb.SetFields("name, video_id"),
        igdb.SetFilter("id", igdb.OpContainsAtLeast, "48965"),
    )

videos, err := IGDB.GameVideos.Index(options)

Doesn't Work:

options := igdb.ComposeOptions(
        igdb.SetLimit(limit),
        igdb.SetOffset(offset),
        igdb.SetFields("name, video_id"),
        igdb.SetFilter("name", igdb.OpContainsAtLeast, "Announcement Trailer"),
    )

videos, err := IGDB.GameVideos.Index(options)

We get the following error with the above request: Error: cannot get index of GameVideos: cannot make POST request: igdb server error: status: 400 message: bad request: check query parameters

Any thoughts on how we can fix this?

Thanks!

Akecel commented 1 year ago

@HammerMeetNail Hello ! I got the same error for Company (filter by name), any news about that ? Did you find a trick ?

HammerMeetNail commented 1 year ago

@Akecel it's been awhile, but I recall just forking the repo and updating the struct. Love this project, but I think at this point it's been abandoned.