Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

166
Views
Spotify Web API returns 404 with valid show id

I'm trying out the WebAPI and have run into a snag that doesn't make sense.

In the developer console a search for the episode list for show id 4rOoJ6Egrf8K2IrywzwOMk returns a list.

Even accessing the given URL (https://api.spotify.com/v1/shows/4rOoJ6Egrf8K2IrywzwOMk/episodes) in the browser returns the episode list, if I'm logged into my spotify account.

I'm not sure what's broken in my code.

async function listPodcastEpisodes(id) {
  const access_token = await getAuth()
  const api_url = `https://api.spotify.com/v1/shows/${id}/episodes`
  console.log(api_url)
  try {
    const response = await axios.get(api_url, setAxiosOptions(access_token))
    return response.data
  } catch(err) {
    console.log(`Error: ${JSON.stringify(err?.response?.data, null, 2)}`)
  }
}

listPodcastEpisodes(process.argv[2])
  .then(x => console.log(x))

This code returns:

$ node getInfo.js 4rOoJ6Egrf8K2IrywzwOMk
https://api.spotify.com/v1/shows/4rOoJ6Egrf8K2IrywzwOMk/episodes
Error: {
  "error": {
    "status": 404,
    "message": "non existing id"
  }
}
undefined

The other functions and variable settings:

const auth = `${process.env.ID}:${process.env.SECRET}`
const auth_encoded = Buffer.from(auth, 'utf-8').toString("base64")

function setAxiosOptions(data) {
  return {
    headers: {
      'Authorization': `Bearer ${data}`,
      'Content-Type': 'application/json'
    }
  }
}

async function getAuth () {
  try {
    const token_url = 'https://accounts.spotify.com/api/token';
    const data = qs.stringify({'grant_type':'client_credentials'});
    const response = await axios.post(token_url, data, {
      headers: { 
        'Authorization': `Basic ${auth_encoded}`,
        'Content-Type': 'application/x-www-form-urlencoded' 
      }
    })

    return response.data.access_token;
  } catch(error) {
    console.log(error);
  }
}
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

It looks like you may need to include the market parameter.

I found this GitHub issue on the official Web API repo describing the same problem you're experiencing. This issue is referenced by this issue, where GitHub user MrXyfir posts their workaround:

Edit: For anyone else who ends up with this issue, the solution for me was to set the market param. https://api.spotify.com/v1/shows/4rOoJ6Egrf8K2IrywzwOMk/episodes?market=US

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!