rspotify icon indicating copy to clipboard operation
rspotify copied to clipboard

Json Parsing error internal

Open Jacob-Tate opened this issue 1 year ago • 1 comments

Describe the bug When attempting to use the show query code I get the following error this doesnt occur on the track search

To Reproduce

let creds = Credentials::new("redacted","redacted");
let client = ClientCredsSpotify::new(creds);
client.request_token().await.unwrap();

let show_query = "love";
let result = client.search(show_query, SearchType::Show, None, None, Some(10), None).await;
match result {
     Ok(show) => println!("Searched show: {show:?}"),
     Err(err) => println!("Search error! {err:?}"),
}

Log/Output data Search error! ParseJson(Error("invalid type: null, expected struct SimplifiedShow", line: 4, column: 20))

Jacob-Tate avatar Aug 09 '24 00:08 Jacob-Tate

I can reproduce this problem with curl:

·> curl --request GET \
  --url 'https://api.spotify.com/v1/search?limit=10&q=love&type=show' \
  --header 'Authorization: Bearer MyToken'
{
  "shows" : {
    "href" : "https://api.spotify.com/v1/search?query=love&type=show&offset=0&limit=10",
    "items" : [ null, null, null, null, null, null, null, null, null, null ],
    "limit" : 10,
    "next" : "https://api.spotify.com/v1/search?query=love&type=show&offset=10&limit=10",
    "offset" : 0,
    "previous" : null,
    "total" : 209
  }
}%

According to the Spotify's document:

If a valid user access token is specified in the request header, the country associated with the user account will take priority over this parameter. Note: If neither market or user country are provided, the content is considered unavailable for the client. Users can view the country that is associated with their account in the account settings.

You have not specified any country in your request, it means Spotify was using the country associated with your account, if you haven't set a country in your account setting, no show is available for you, so it return list of null.

In order to fix the above problem, you could simply specify a country like market=US

ramsayleung avatar Sep 13 '24 07:09 ramsayleung

This problem should be fixed by this PR https://github.com/ramsayleung/rspotify/pull/526/files, you could consume the 0.15.0 to solve this problem.

ramsayleung avatar Jul 08 '25 17:07 ramsayleung