SteamKit icon indicating copy to clipboard operation
SteamKit copied to clipboard

Parse response body when Web API returns an error?

Open RudeySH opened this issue 5 years ago • 0 comments

A previous release made it possible to find the status code when Web API returns an error (#517). I would now like to be able to parse the response body of the request when an error occurs.

It turns out Steam sometimes returns the same status code for different kinds of errors. The response body will contain a distinct message, though. For example, when calling ISteamUserStats/GetPlayerAchievements, Steam could respond with a 403 (Forbidden), which either means that the request was rate-limited, or it could mean that the player has a private profile. When the latter occurs, the response body looks like this:

{
    "playerstats": {
        "error": "Profile is not public",
        "success": false
    }
}

Can WebAPIRequestException or SteamKitWebRequestException be extended to include a KeyValue property for the response body?

RudeySH avatar Nov 03 '19 21:11 RudeySH