Announcements

Help Wizard

Step 1

NEXT STEP

Search for shows returns an array of null

Search for shows returns an array of null

When querying the search api for shows I am getting a successful response but items is returned as an array of null.

Here's my request:

 

url: "https://api.spotify.com/v1/search?q=masters&type=show",
method: "get",
headers: {
Authorization: "Bearer " + token,
Accept: "application/json",
"Content-Type": "application/json",
},

 

 

This is what I get back: 

 

{ href:
'https://api.spotify.com/v1/search?query=masters&type=show&offset=0&limit=20',
items:
[ null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null ],
limit: 20,
next:
'https://api.spotify.com/v1/search?query=masters&type=show&offset=20&limit=20',
offset: 0,
previous: null,
total: 5783 }

 

 

Any ideas?!
Reply
4 Replies

Hi Jonny. Are you using the client credentials flow to obtain an authorization token? If so, then you might want to try including the market URL parameter: https://developer.spotify.com/documentation/web-api/reference/search/search/

I've noticed this also, however in the documentation for other endpoints for Shows e.g. Get a Show's Episodes. It mentions that If neither market or user country are provided, the content is considered unavailable for the client. I've noticed if you do provide a "market" e.g. "GB" you don't get this list of nulls when doing Search for an Item.

This suggestion of adding market query parameter fixed problem in my case.

 

Previous non-working query

REQUEST

https://api.spotify.com/v1/shows/2yB9jTRog4XGCKG5bpNZUA

RESPONSE

{
    "error": {
        "status": 404,
        "message": "non existing id"
    }
}

Working query

 

REQUEST

GET https://api.spotify.com/v1/shows/2yB9jTRog4XGCKG5bpNZUA?market=FI

 RESPONSE

{
    "available_markets": [
        // Cut out
    ],
    "copyrights": [],
    "description": "The AIAS Game Maker’s Notebook is a podcast featuring a series of in-depth, one-on-one conversations between game makers. Each episode is hosted by a fellow game maker and provides a thoughtful, intimate perspective on the business and craft of interactive entertainment that will explore the tenants of D.I.C.E.; Design, Innovate, Communicate, and Entertain.",
    "episodes": {
        "href": "https://api.spotify.com/v1/shows/2yB9jTRog4XGCKG5bpNZUA/episodes?offset=0&limit=50&market=FI",
        "items": [
            // Cut out episodes...

            {
                "audio_preview_url": "https://p.scdn.co/mp3-preview/b6b67e9c7661eee91417af60ba55c0320f6d68a0",
                "description": "Siobhan Reddy (LittleBigPlanet) sits down with Ted to talk about the upcoming game Dreams, the importance of community support, user-generated content, and the \"glitter and doom\" that comes with being a game developer. Reddy is the co-founder and studio director of Media Molecule. The studio is best known for their title LittleBigPlanet. For news and info on the AIAS, follow us on Twitter @Official_AIAS, Facebook or visit us at interactive.org. Email us at *snip*.",
                "duration_ms": 3514944,
                "explicit": false,
                "external_urls": {
                    "spotify": "https://open.spotify.com/episode/36SMkU9lPQUq85NQQBWET7"
                },
                "href": "https://api.spotify.com/v1/episodes/36SMkU9lPQUq85NQQBWET7",
                "id": "36SMkU9lPQUq85NQQBWET7",
                "images": [
                    {
                        "height": 640,
                        "url": "https://i.scdn.co/image/50a1d65377814fea4446a51f05c2a29d5231dbbe",
                        "width": 640
                    },
                    {
                        "height": 300,
                        "url": "https://i.scdn.co/image/e599b62b786ed24e455ecad8a454832ba03886b1",
                        "width": 300
                    },
                    {
                        "height": 64,
                        "url": "https://i.scdn.co/image/529732d4cc66f8bfd164169d7200eb17b08242dc",
                        "width": 64
                    }
                ],
                "is_externally_hosted": false,
                "is_playable": true,
                "language": "en",
                "languages": [
                    "en"
                ],
                "name": "Media Molecule's Siobhan Reddy",
                "release_date": "2018-07-03",
                "release_date_precision": "day",
                "type": "episode",
                "uri": "spotify:episode:36SMkU9lPQUq85NQQBWET7"
            }
        ],
        "limit": 50,
        "next": "https://api.spotify.com/v1/shows/2yB9jTRog4XGCKG5bpNZUA/episodes?offset=50&limit=50&market=FI",
        "offset": 0,
        "previous": null,
        "total": 63
    },
    "explicit": false,
    "external_urls": {
        "spotify": "https://open.spotify.com/show/2yB9jTRog4XGCKG5bpNZUA"
    },
    "href": "https://api.spotify.com/v1/shows/2yB9jTRog4XGCKG5bpNZUA",
    "id": "2yB9jTRog4XGCKG5bpNZUA",
    "images": [
        {
            "height": 640,
            "url": "https://i.scdn.co/image/d8654ac47ca21c03372a05a62c31ffcc52019e71",
            "width": 640
        },
        {
            "height": 300,
            "url": "https://i.scdn.co/image/016737ee1188f0eb34284e0b86761f52c097b0fc",
            "width": 300
        },
        {
            "height": 64,
            "url": "https://i.scdn.co/image/92b4b89483a4463f124db85fe4874caae814c81c",
            "width": 64
        }
    ],
    "is_externally_hosted": false,
    "languages": [
        "en"
    ],
    "media_type": "audio",
    "name": "The AIAS Game Maker's Notebook",
    "publisher": "The Academy of Interactive Arts & Sciences",
    "total_episodes": 63,
    "type": "show",
    "uri": "spotify:show:2yB9jTRog4XGCKG5bpNZUA"
}

Thanks for this, providing a market does fix things.

 

That said, a 404 response for this request (https://api.spotify.com/v1/episodes/512ojhOuo1ktJprKbVcKyQ) is wrong and totally useless to developers.

 

Why require a market to begin with? The endpoint response returns `available_markets`.

 

If y'all must require that query parameter, then please at least use the correct response code (400).

Feel free to read up on it's usage here: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/400

Suggested posts