Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

167
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda