3

How would i access the "leaguePoints"?

    using (var http = new HttpClient())
    {
        var result = JObject.Parse(await http.GetStringAsync($"https://euw.api.riotgames.com/api/lol/EUW/v2.5/league/by-summoner/12345678/entry?api_key=" + apikey).ConfigureAwait(false));
        var something = (Uri.EscapeUriString(result["12345678"][0]["tier"]["leaguePoints"].ToString()));
    }

I also tried adding an [0] after ["tier"], but in both scenarios it gives me the error

Cannot access child value on Newtonsoft.Json.Linq.JValue.

Json example response below:

{
    "12345678": [
        {
            "tier": "PLATINUM",
            "queue": "RANKED_SOLO_5x5",
            "name": "Taric's Templars",
            "entries": [
                {
                    "isFreshBlood": false,
                    "division": "III",
                    "isVeteran": false,
                    "wins": 9,
                    "losses": 1,
                    "playerOrTeamId": "12345678",
                    "playerOrTeamName": "noname123",
                    "isInactive": false,
                    "isHotStreak": false,
                    "leaguePoints": 0
                }
            ]
        }
    ]
}

1 Answer 1

10

"leaguePoints" seems to be in "entries" rather than in "tier":

 result["12345678"][0]["entries"][0]["leaguePoints"]
Sign up to request clarification or add additional context in comments.

2 Comments

I am so dumb .-. Thanks alot!
How to check if it exists in ["tier"] and if doesn'T switch to check whether it exists in ["entries"]?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.