错误代码 50035,预期 "Content-Type" header 是 {'application/json'} 之一

Error code 50035, Expected "Content-Type" header to be one of {'application/json'}

当运行:

dotenv.config()
const clientId = process.env.CLIENTID
const guildId = process.env.GUILDID
const token = process.env.TOKEN

const rest = new REST({ version: '9' }).setToken(token);
rest.get(Routes.applicationGuildCommands(clientId, guildId))
    .then((data: any) => {
        const promises = [];
        for (const command of data) {
            const deleteUrl = `${Routes.applicationGuildCommands(clientId, guildId)}/${command.id}`;
            promises.push(rest.delete(deleteUrl));
        }
        return Promise.all(promises);
    })
    .then(rest.put(Routes.applicationGuildCommands(clientId, guildId), { body: commands }))

要删除我保存的公会斜杠命令,我收到错误消息:

D:\Discord Bot\node_modules\@discordjs\rest\src\lib\handlers\SequentialHandler.ts:477
                                throw new DiscordAPIError(data, data.code, res.status, method, url, bodyData);
          ^
w[50035]: Invalid Form Body
0[CONTENT_TYPE_INVALID]: Expected "Content-Type" header to be one of {'application/json'}.
    at Z.runRequest (D:\Discord Bot\node_modules\@discordjs\rest\src\lib\handlers\SequentialHandler.ts:477:11)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async Z.queueRequest (D:\Discord Bot\node_modules\@discordjs\rest\src\lib\handlers\SequentialHandler.ts:200:11) {
  rawError: {
    code: 50035,
    errors: { _errors: [Array] },
    message: 'Invalid Form Body'
  },
  code: 50035,
  status: 400,
  method: 'put',
  url: 'https://discord.com/api/v9/applications/925211738931073044/guilds/785314186979835924/commands',
  requestBody: { attachments: undefined, json: undefined }
}

我不知道是什么导致了这个问题,但对我来说不是很明显所以希望这里有人知道这个问题?

事实证明,删除 .then(rest.put(Routes.applicationGuildCommands(clientId, guildId), { body: commands })) 从代码修复它