YouTube.js icon indicating copy to clipboard operation
YouTube.js copied to clipboard

13.1.0 uploading video failed with 400 status code

Open FightFarewellFearless opened this issue 9 months ago • 3 comments

Steps to reproduce

  1. Run yt.studio.upload
  2. It failed with 400 Request contains an invalid argument. error

My code:

import { Innertube } from 'youtubei.js';
import fs from 'fs';

const video = fs.readFileSync('./video.mp4');

const innertube = await Innertube.create({
    cookie: process.env.YT_COOKIE
});

const videoId = await innertube.studio.upload(video.buffer, {
    title: "This is test video",
    privacy: "PRIVATE",
    description: 'Hello this is a test video!'
});

console.log(
    JSON.stringify(
        videoId
        , null, 2
    )
);

Failure Logs

throw new InnertubeError(`Request to ${response.url} failed with status ${response.status}`, await response.text());
              ^

InnertubeError: Request to https://www.youtube.com/youtubei/v1/upload/createvideo?prettyPrint=false&alt=json failed with status 400

    at HTTPClient.fetch (file:///home/xx/Documents/project/xx/node_modules/youtubei.js/dist/src/utils/HTTPClient.js:115:15)
    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
    at async Actions.execute (file:///home/xx/Documents/project/xx/node_modules/youtubei.js/dist/src/core/Actions.js:67:26)
    at async Studio._Studio_setVideoMetadata (file:///home/xx/Documents/project/xx/node_modules/youtubei.js/dist/src/core/clients/Studio.js:172:12)
    at async Studio.upload (file:///home/xx/Documents/project/xx/node_modules/youtubei.js/dist/src/core/clients/Studio.js:125:16)
    at async file:///home/xx/Documents/project/xx/upload.js:15:17 {

'{\n' +
    '  "error": {\n' +
    '    "code": 400,\n' +
    '    "message": "Request contains an invalid argument.",\n' +
    '    "errors": [\n' +
    '      {\n' +
    '        "message": "Request contains an invalid argument.",\n' +
    '        "domain": "global",\n' +
    '        "reason": "badRequest"\n' +
    '      }\n' +
    '    ],\n' +
    '    "status": "INVALID_ARGUMENT"\n' +
    '  }\n' +
    '}\n',
  date: 2025-03-20T01:36:01.380Z,
  version: '13.1.0'
}

Node.js v23.10.0

Expected behavior

Video uploaded successfully without any error

Current behavior

It failed with status code 400 Request contains an invalid argument.

Version

Default

Anything else?

No response

Checklist

  • [x] I am running the latest version.
  • [x] I checked the documentation and found no answer.
  • [x] I have searched the existing issues and made sure this is not a duplicate.
  • [x] I have provided sufficient information.

FightFarewellFearless avatar Mar 20 '25 01:03 FightFarewellFearless