I get a 500 error when I add 'madeForKids' parameter to 'youtube.liveBroadcasts.insert' API

妖精的绣舞 提交于 2021-02-08 05:18:38

问题


I have one question about how to use 'madeForKids' in 'youtube.liveBroadcasts.insert' API.

When I don't use this parameter, the user interface of youtube will pop up a window to let me choose wether it is made for kids. I don't want it to show this window. I want to set this value with API. But when I added this parameter, it will always response a 500 error.

My codes is based on JS as follows:

    this.youtube.liveBroadcasts.insert(
      {
        auth: this.oauth2Client,
        part: "snippet,contentDetails,status",
        resource: {
          snippet: {
            title: title,
            scheduledStartTime: scheduledStartTime
          },
          status: {
            madeForKids: "false",
            selfDeclaredMadeForKids: "false",
            lifeCycleStatus: "live",
            privacyStatus: "public"
          },
          contentDetails: {
            rojection: "360",
            monitorStream: {
              enableMonitorStream: false
            }
          }
        }
      },
      function (err, response) {
        if (err) {
          console.log("The API:createLiveBroadCast returned an error: " + err);
          reject(new Error(err));
        } else {
          console.log(response);
          resolve(response);
        }
      }
    );

Additionally, I am using the latest googleapis: "^48.0.0".

Can anyone help me ? Thanks a lot !


回答1:


You cannot set the status attribute in LiveBroadcast. After you insert LiveBroadcast, you must update the video asset and set the status attributes there. Use the LiveBroadcast.ID you just added. You must reset the title and description at the same time or they will get set to null.

Like this:

       var videoRequest = youtubeService.Videos.Update(
            new Video {
                Id = "xxxxxx",
                Kind = "youtube#video",
                Snippet = new VideoSnippet
                {
                    Title = "updated title",
                    CategoryId = "28"
                },
                Status = new VideoStatus
                {
                    PrivacyStatus = "unlisted",
                    SelfDeclaredMadeForKids = false
                }
            },
            "snippet,status"
        );
        var videoResponse = videoRequest.Execute();



回答2:


When calling for liveBroadcasts.insert endpoint, if wanting to designate the respective broadcast as child-directed, you shoudn't use the makeForKids property, but this one instead:

status.selfDeclaredMadeForKids: boolean

In a liveBroadcasts.insert request, this property allows the channel owner to designate the broadcast as being child-directed. In a liveBroadcasts.list request, the property value is only returned if the channel owner authorized the API request.

See the list of properties allowed to be used by this endpoint. It mentions selfDeclaredMadeForKids but not madeForKids!



来源:https://stackoverflow.com/questions/60824642/i-get-a-500-error-when-i-add-madeforkids-parameter-to-youtube-livebroadcasts

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!