JohnnyCrazy / SpotifyAPI-NET

:sound: A Client for the Spotify Web API, written in C#/.NET
http://johnnycrazy.github.io/SpotifyAPI-NET/
MIT License
1.52k stars 310 forks source link

JsonReaderException when getting Artist. #928

Closed rogamaral closed 9 months ago

rogamaral commented 11 months ago

Spotify changed, at least in the artist endpoint, the int types to float/double.

{
    "external_urls": {
        "spotify": "https://open.spotify.com/artist/7Ln80lUS6He07XvHI8qqHH"
    },
    "followers": {
        "href": null,
        "total": 2.3024383E7
    },
    "genres": [
        "garage rock",
        "modern rock",
        "permanent wave",
        "rock",
        "sheffield indie"
    ],
    "href": "https://api.spotify.com/v1/artists/7Ln80lUS6He07XvHI8qqHH",
    "id": "7Ln80lUS6He07XvHI8qqHH",
    "images": [
        {
            "url": "https://i.scdn.co/image/ab6761610000e5eb7da39dea0a72f581535fb11f",
            "height": 640.0,
            "width": 640.0
        },
        {
            "url": "https://i.scdn.co/image/ab676161000051747da39dea0a72f581535fb11f",
            "height": 320.0,
            "width": 320.0
        },
        {
            "url": "https://i.scdn.co/image/ab6761610000f1787da39dea0a72f581535fb11f",
            "height": 160.0,
            "width": 160.0
        }
    ],
    "name": "Arctic Monkeys",
    "popularity": 85.0,
    "type": "artist",
    "uri": "spotify:artist:7Ln80lUS6He07XvHI8qqHH"
}
sercangunver commented 10 months ago

I created a pull request for this problem.

JohnnyCrazy commented 10 months ago

Seems like spotify is currently on a run with breaking things!

Same to the other issue, did you guys find any information if this is an intended change?

JohnnyCrazy commented 10 months ago

https://community.spotify.com/t5/Spotify-for-Developers/Get-Artist-reference-bug-receiving-Float-instead-of-Int/m-p/5800203

https://community.spotify.com/t5/Spotify-for-Developers/The-response-type-of-artist-endpoint-is-marked-as-Integer-in/m-p/5800044

rogamaral commented 10 months ago

I haven't found anything that says it's intentional. Just a few guys complaining about the same thing, the two you listed plus this one: https://community.spotify.com/t5/Spotify-for-Developers/Get-Artist-API-endpoint-responds-with-result-in-inconsistent/td-p/5806916

laurilubi commented 10 months ago

I ran into the same problem today. I haven't checked Spotifys JSON schema, but if it is a number (not integer) then exponential notation should be allowed. https://json-schema.org/understanding-json-schema/reference/numeric#number

laurilubi commented 10 months ago

I ran into the same problem today. I haven't checked Spotifys JSON schema, but if it is a number (not integer) then exponential notation should be allowed. https://json-schema.org/understanding-json-schema/reference/numeric#number

I went for a workaround with implementing own IJSONSerializer and class CustomIntConverter : JsonConverter<int> where ReadJson() converts to int.

JohnnyCrazy commented 9 months ago

Should be fixed in SpotifyAPI Web 7.1.1

Feel free to re-open if that's not the case.