Skip to content

Parse response body when Web API returns an error? #778

@RudeySH

Description

@RudeySH

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?

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions