Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

223
Vistas
How to do Spotify Api Post Request using Axios

I'm trying to add a song to the playback queue using this endpoint:

   const add = async () => {
   

    try {
      
      const url = `https://api.spotify.com/v1/me/player/queue?uri=${songUrl}&device_id=${deviceId}`
     
      await axios.patch(url, {
        headers: {
            Authorization: `Bearer ${to}`
        },
    })
    } catch (error) {
      console.log(error);
    }
   
   
}

I'm getting a status 401 error with a message that says no token provided. But when I console.log the token it shows up.

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

I haven't worked with the Spotify API yet, however, according to their docs, you need to send a POST request, not a PATCH, which is what you used.

Use axios.post() instead of axios.patch():

const add = async (songUrl, deviceId, token) => {
  try {
    const url = `https://api.spotify.com/v1/me/player/queue?uri=${songUrl}&device_id=${deviceId}`;

    await axios.post(url, {
      headers: {
        Authorization: `Bearer ${token}`,
      },
    });
  } catch (error) {
    console.log(error);
  }
};
about 4 years ago · Juan Pablo Isaza Denunciar

0

The second param of your post request should be body and the third param should be headers. Also, you haven't added all the headers as mentioned in the documentation.

headers: {
      Accept: 'application/json',
      Authorization: 'Bearer ' + newAccessToken,
      'Content-Type': 'application/json',
}

Get your access token from here: https://developer.spotify.com/console/post-queue/

If it still doesn't work try the curl method as mentioned in their docs and if it works, switch it to axios.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda