user2985035
user2985035

Reputation: 569

How to structure the snippet and status in JSON for v3 YouTube API upload

I'm uploading videos to YouTube using the following API "https://www.googleapis.com/upload/youtube/v3/videos?part=snippet,status" and sending the upload values in "options" object array.

Like this:

options.headers = {
    Authorization: "Bearer " + accessToken,
    "Access-Control-Allow-Origin": "mysite.com"
  };

options.snippet = {
                title: 'Video title',
                description: 'Video description',
                tags: 'Video tags',
                categoryId: 22
            };

options.status= {
                privacyStatus: 'private'
            }; 

The video is uploaded with no problem but the snippet and status key values are not sent to YouTube!

What is wrong with my JSON structure? I tried to include the snippet and status under options.part but failed also.

Upvotes: 1

Views: 246

Answers (1)

JAL
JAL

Reputation: 42449

According to the documentation, the tags key needs to be an array of strings, not a single string. It's possible that passing in a single string is causing the values to be invalidated.

tags: [ "tag1", "tag2", "tag3" ]

Make an API call for any video on YouTube and you will see the tags are in this format: https://developers.google.com/youtube/v3/docs/videos/list

options.snippet = {
            title: 'Video title',
            description: 'Video description',
            tags: [ 'tag1', 'tag2', 'tag3' ],
            categoryId: 22
        };

Upvotes: 1

Related Questions