You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用Spotify API添加歌曲到队列时出现404错误求助

Spotify API 添加曲目到队列时持续返回404错误

我的Spotify URI数组格式如下:

spotify:track:3OF9rTCYjLEplmYMynYvHG

我尝试用以下代码将数组中的每个值添加到队列:

for (const uri of array.slice(0, max)) {
    let result = await fetch(`https://api.spotify.com/v1/me/player/queue?uri=${uri}`, {
        method: 'POST',
        headers: {
            'Authorization': `Bearer ${token}`,
            'Content-Type': 'application/json',
        }
    });

    console.log(result);

    if (result.status === 404) {
        console.log(`Track not found in Spotify catalog: ${uri}`);
    } else if (result.ok) {
        console.log(`Successfully added ${uri} to queue`);
    } else {
        console.log(`Error adding ${uri} to queue. Status: ${result.status}`);
    }
}

持续遇到以下错误:

Track not found in Spotify catalog: spotify:track:3OF9rTCYjLEplmYMynYvHG

完整响应内容如下:

Response {
size: 0,
timeout: 0,
[Symbol(Body internals)]: {
 body: Gunzip {
  _writeState: [Uint32Array],
  _readableState: [ReadableState],
  _events: [Object: null prototype],
  _eventsCount: 5,
  _maxListeners: undefined,
  _writableState: [WritableState],
  allowHalfOpen: true,
  bytesWritten: 0,
  _handle: [Zlib],
  _outBuffer: <Buffer 00 00 00 00 00 00 00 00 97 00 00 00 00 00 00 00 00 00 00 00 00 
 00 00 00 97 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
 00 ... 16334 more bytes>,
  _outOffset: 0,
  _chunkSize: 16384,
  _defaultFlushFlag: 2,
  _finishFlushFlag: 2,
  _defaultFullFlushFlag: 3,
  _info: undefined,
  _maxOutputLength: 4294967296,
  _level: -1,
  _strategy: 0,
  [Symbol(kCapture)]: false,
  [Symbol(kCallback)]: null,
  [Symbol(kError)]: null
},
disturbed: false,
error: null
  },
 [Symbol(Response internals)]: {
  url: 'https://api.spotify.com/v1/me/player/queue?uri=spotify:track:3OF9rTCYjLEplmYMynYvHG',
status: 404,
statusText: 'Not Found',
headers: Headers { [Symbol(map)]: [Object: null prototype] },
counter: 0
  }
}

已做的排查:

  • 执行音频分析时能正常读取该歌曲,仅添加到队列操作出错
  • 打印access token显示正常,其他API请求可正常工作
  • 此前功能正常,拆分代码到不同HTML页面后出现该问题
  • 尝试仅使用Spotify ID而非完整URI,问题仍未解决

恳请各位提供帮助,谢谢!

内容的提问来源于stack exchange,提问作者Lara-Codes

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.12 22:05:55