babelshift / SteamWebAPI2

🎮 C# / .NET library that makes it easy to use the Steam Web API. It conveniently wraps around all of the JSON data and ugly API details with clean methods, structures and classes.
MIT License
263 stars 43 forks source link

OwnedGamesResultModel returns null properties #101

Closed theaswanson closed 4 years ago

theaswanson commented 4 years ago

I'm trying to use the PlayerService to return my list of games. I get my list of games back, but several of the OwnedGameModel properties are null, including Name, ImgIconUrl, and ImgLogoUrl.

Here's my code:

public async Task < IActionResult > Get(ulong id) {
    var webInterfaceFactory = new SteamWebInterfaceFactory("my api key");
    var steamInterface = webInterfaceFactory.CreateSteamWebInterface < PlayerService > (new HttpClient());
    var response = await steamInterface.GetOwnedGamesAsync(id);
    var games = response.Data;
    return Ok(games);
}

Sample result: image

babelshift commented 4 years ago

@theaswanson the IPlayerService/GetOwnedGames endpoint will, by default, only return appid and playtime stats. You will need to set the includeAppInfo parameter to true to include other information about the owned games. That's just how Valve setup this endpoint. Please let me know if that resolves your issue.

theaswanson commented 4 years ago

Ah, my bad. I didn't look at the rest of the optional parameters: GetOwnedGamesAsync(ulong steamId, bool? includeAppInfo = null, bool? includeFreeGames = null, IReadOnlyCollection<uint> appIdsToFilter = null); I'm sure that'll fix my issue. I'll give it a shot and see if it works.

theaswanson commented 4 years ago

I was able to fix my issue by changing my code like this:

public async Task < IActionResult > Get(ulong id) {
    ...
    var response = await steamInterface.GetOwnedGamesAsync(id, true, true);
    ...
}