title: Spotify Web API - How to play a playlist
body: <p>I'm trying to get my hands on the Spotify API, but I don't know how to play a playlist or album. See my code below:</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>// Called when the Spotify Web Playback SDK is ready to use
  window.onSpotifyWebPlaybackSDKReady = () =&gt; {  
    // Define the Spotify Connect device, getOAuthToken has an actual token
    // hardcoded for the sake of simplicity
    var player = new Spotify.Player({
      name: "A Spotify Web SDK Player",
      getOAuthToken: (callback) =&gt; {
        callback(
          "&lt;Token to be placed here&gt;"
        );
      },
      volume: 0.3,
    });
  
    // Called when connected to the player created beforehand successfully
    player.addListener("ready", ({ device_id }) =&gt; {
      console.log("Ready with Device ID", device_id);
  
      const play = ({
        context_uri,
        playerInstance: {
          _options: { getOAuthToken, id },
        },
      }) =&gt; {
        getOAuthToken((access_token) =&gt; {
          fetch(
            `https://api.spotify.com/v1/me/player/play?device_id=${device_id}`,
            {
              method: "PUT",
              body: JSON.stringify({ uris: [context_uri] }),
              headers: {
                "Content-Type": "application/json",
                Authorization: `Bearer ${access_token}`,
              },
            }
          );
        });
      };
  
      play({
        playerInstance: player,
        context_uri: "spotify:playlist:37i9dQZF1EIZKYrELNKNNT",
        position_ms: 0,
      });
    });
  
    // Connect to the player created beforehand, this is equivalent to
    // creating a new device which will be visible for Spotify Connect
    player.connect();
    console.log("playing?");
  };</code></pre>
  </div>
  </div>
  </p>
  <p>The actual problem is this part:
  <code>context_uri: &quot;spotify:playlist:37i9dQZF1EIZKYrELNKNNT</code></p>
  <p>This will return 400 error:</p>
  <pre><code>{
    &quot;error&quot; : {
      &quot;status&quot; : 400,
      &quot;message&quot; : &quot;Unsupported uri kind: playlist_v2&quot;
    }
  }
  </code></pre>
  <p>If I replace it with specific track uri, for instance <code>spotify:track:72boGlgSwUK01n44O2tOCv</code> everything works fine.</p>
  <p><strong>How can I pass a playlist uri instead of a specific track?</strong></p>