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

187
Vistas
Getting 401 error while making a PUT request to the Spotify API

I am trying to make a put request to create a playlist for a user and I keep getting a status: 401, message: "No token provided" error. Can someone help me take a look at my code and tell me what I am doing wrong?

    const createNewPlaylist = () => {
    var user_id = ''
    axios.get(' https://api.spotify.com/v1/me',{

        headers:{
            'Authorization':"Bearer " + localStorage.getItem("accessToken")
        }

    }).then((response)=>{
        user_id = response.data.id
        console.log(localStorage.getItem("accessToken"))
        axios.post('https://api.spotify.com/v1/users/'+user_id+'/playlists',
        {
            headers:{
                'Authorization':"Bearer " + localStorage.getItem("accessToken")
            },
            data:{
                "name": "huhsss",
                "description": "New playlist description",
                "public": false
            }
        }

    ).then((res)=>{
            console.log(res)
    })

    })
}

I have already added all the required scopes for this specific call and my token actually works for every other requests I make. It even works for the first GET request I make.

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

0

For an axios post request, the data is the second argument and options (including headers) are the third argument:

axios.post(
  "https://api.spotify.com/v1/users/" + user_id + "/playlists",
  {
    name: "huhsss",
    description: "New playlist description",
    public: false,
  },
  {
    headers: {
      Authorization: "Bearer " + localStorage.getItem("accessToken"),
    },
  }
);
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