apiyoutubeyoutube-apiyoutube-data-apiandroid-youtube-api

How to upload a video to YouTube using the API?


I am trying to use POST request to publish a video on YouTube using this official tutorial Videos: insert

Request URL:

https://youtube.googleapis.com/youtube/v3/videos?part=snippet%2Cstatus&access_token=[[I_FILE_ACCES_TOKEN]]&key=[[E_FILE_AKKOV_API_KEY]]

body of POST request:

{
  "snippet": {
    "categoryId": "22",
    "description": "Description of uploaded video.",
    "title": "Test video upload.",
    "tags": [
      "музыка, song, classic"
    ],
    "defaultLanguage": "ru",
    "thumbnails": {
      "default": {
        "url": "url of jpg image"
      }
    }
  },
  "status": {
    "privacyStatus": "private",
    "license": "youtube"
  }
}

Question: "Where in the spippet is the path to the mp4 file of the disk that needs to be uploaded to YouTube?"

Naturally, it gives an error because there is a problem with the arguments in the snippet:

Url: https://youtube.googleapis.com/youtube/v3/videos?part=snippet%2Cstatus&access_token=ya29.adpsecret65&key=AIzaSyAo1secretZM_auU
Status: 400

Vary: X-Origin
Vary: Referer
Content-Type: application/json; charset=UTF-8
Date: Thu, 01 Sep 2022 17:52:06 GMT
Server: scaffolding on HTTPServer2
Cache-Control: private
X-XSS-Protection: 0
X-Frame-Options: SAMEORIGIN
X-Content-Type-Options: nosniff
Accept-Ranges: none
Vary: Origin,Accept-Encoding
Transfer-Encoding: chunked
Alt-Svc: h3=":443"; ma=2592000,h3-29=":443"; ma=2592000,h3-Q050=":443"; ma=2592000,h3-Q046=":443"; ma=2592000,h3-Q043=":443"; ma=2592000,quic=":443"; ma=2592000; v="46,43"

{
  "error": {
    "code": 400,
    "message": "Request contains an invalid argument.",
    "errors": [
      {
        "message": "Request contains an invalid argument.",
        "domain": "global",
        "reason": "badRequest"
      }
    ],
    "status": "INVALID_ARGUMENT"
  }
}

Solution

  • "Where in the spippet is the path to the mp4 file of the disk that needs to be uploaded to YouTube?"

    No where the snippet is just the metadata for the video.

    The video is uploaded separately you may want to consult media-upload