This document identifies the different types of errors that YouTube Data API operations can return. You can also find a list of errors for any individual method in the reference documentation for that method.
General errors
The following tables identify API error messages that are not specific to a particular API method.
Core API errors
Error type | Error detail | Description |
---|---|---|
forbidden (403) |
forbidden |
Access forbidden. The request may not be properly authorized. |
quotaExceeded (403) |
quotaExceeded |
The request cannot be completed because you have exceeded your quota. |
Common request errors
Error type | Error detail | Description |
---|---|---|
badRequest (400) |
incompatibleParameters |
The request specifies two or more parameters that cannot be used in the same request. |
badRequest (400) |
invalidFilters |
The request specifies an invalid filter parameter. |
badRequest (400) |
invalidPageToken |
The request specifies an invalid page token. |
badRequest (400) |
missingRequiredParameter |
The request is missing a required parameter. |
badRequest (400) |
unexpectedParameter |
The request specifies an unexpected parameter. |
forbidden (403) |
accountDelegationForbidden |
The authenticated user cannot act on behalf of the specified Google account. |
forbidden (403) |
authenticatedUserAccountClosed |
The YouTube account of the authenticated user is closed. In case the authenticated user is acting on behalf of another Google account, then this error refers to the latter. |
forbidden (403) |
authenticatedUserAccountSuspended |
The YouTube account of the authenticated user is suspended. In case the authenticated user is acting on behalf of another Google account, then this error refers to the latter. |
forbidden (403) |
authenticatedUserNotChannel |
For this request the authenticated user must resolve to a channel, but does not. If your request is authenticated and uses the onBehalfOfContentOwner delegation parameter, then you should also set the onBehalfOfContentOwnerChannel parameter. |
forbidden (403) |
channelClosed |
The channel identified in the request has been closed. |
forbidden (403) |
channelNotFound |
The channel identified in the request cannot be found. |
forbidden (403) |
channelSuspended |
The channel identified in the request has been suspended. |
forbidden (403) |
cmsUserAccountNotFound |
The CMS user is not allowed to act on behalf of the specified content owner. |
forbidden (403) |
insufficientCapabilities |
The CMS user has insufficient capabilities. |
forbidden (403) |
insufficientPermissions |
The OAuth 2.0 token provided for the request specifies scopes that are insufficient for accessing the requested data. |
notFound (404) |
contentOwnerAccountNotFound |
The specified content owner account was not found. |
Request context errors
Error type | Error detail | Description |
---|---|---|
badRequest (400) |
invalidLanguage |
The hl parameter value does not specify a valid language code. |
badRequest (400) |
invalidMine |
The request’s use of the mine parameter is not supported. |
badRequest (400) |
invalidMine |
The mine parameter cannot be used in requests where the authenticated user is a YouTube partner. You should either remove the mine parameter, authenticate as a YouTube user by removing the onBehalfOfContentOwner parameter, or act as one of the partner’s channels by providing the onBehalfOfContentOwnerChannel parameter if available for the called method. |
badRequest (400) |
invalidPart |
The request’s part parameter specifies some parts that cannot be written at the same time. |
badRequest (400) |
invalidRegionCode |
The regionCode parameter specifies an invalid region code. |
badRequest (400) |
unexpectedPart |
The request’s part parameter specifies an unexpected value. |
badRequest (400) |
unknownPart |
The request’s part parameter specifies an unknown value. |
badRequest (400) |
unsupportedLanguageCode |
The hl parameter value does not specify a supported language code. |
badRequest (400) |
unsupportedRegionCode |
The regionCode parameter specifies an unsupported region code. |
unauthorized (401) |
authorizationRequired |
The request uses the mine parameter but is not properly authorized. |
unauthorized (401) |
youtubeSignupRequired |
This error indicates that the user has an unlinked Google Account, which means that the user has a Google Account but does not have a YouTube channel. Such users can access many features that are dependent on user authorization, such as rating videos or adding videos to a watch_later playlist. However, as an example, the user would need a YouTube channel to be able to upload a video. A user who has a Gmail account or an Android device is certain to have a Google Account but may not have already linked that Google Account to a YouTube channel.
This error is commonly seen if you try to use the OAuth 2.0 Service Account flow. YouTube does not support Service Accounts, and if you attempt to authenticate using a Service Account, you will get this error. The YouTube API blog post introducing Google Account support also discusses the |
activities
YouTube has deprecated the channel bulletin feature. The
activities.insert
method is no
longer supported.
The following tables identify error messages that the API returns in response to calls related to activities
resources. These methods could also return errors listed in the Common errors section.
activities.list
Error type | Error detail | Description |
---|---|---|
forbidden (403) |
homeParameterDeprecated |
The user’s home page activity data is not available through this API. This error might occur if you set the home parameter to true in an unauthorized request. |
forbidden (403) |
forbidden |
The request is not properly authorized. |
notFound (404) |
channelNotFound |
The channel ID identified by the request’s channelId parameter cannot be found. |
notFound (404) |
homeChannelNotFound |
A YouTube home page feed cannot be found for the currently authenticated user. |
unauthorized (401) |
authorizationRequired |
The request uses the home parameter but is not properly authorized. |
captions
The following tables identify error messages that the API returns in response to calls related to captions
resources. These methods could also return errors listed in the Common errors section.
captions.delete
Error type | Error detail | Description |
---|---|---|
forbidden (403) |
forbidden |
The permissions associated with the request are not sufficient to delete the caption track. The request might not be properly authorized. |
notFound (404) |
captionNotFound |
The caption track could not be found. Check the value of the request’s id parameter to ensure that it is correct. |
captions.download
Error type | Error detail | Description |
---|---|---|
forbidden (403) |
forbidden |
The permissions associated with the request are not sufficient to download the caption track. The request might not be properly authorized, or the video order might not have enabled third-party contributions for this caption. |
invalidValue (400) |
couldNotConvert |
The caption track data could not be converted to the requested language and/or format. Ensure that the requested tfmt and tlang values are valid, and that the snippet.status of the requested caption track is not failed . |
notFound (404) |
captionNotFound |
The caption track could not be found. Check the value of the request’s id parameter to ensure that it is correct. |
captions.insert
Error type | Error detail | Description |
---|---|---|
badRequest (400) |
contentRequired |
The request does not contain the caption track contents. |
conflict (409) |
captionExists |
The specified video already has a caption track with the given snippet.language and snippet.name . A video can have multiple tracks for the same language, but each track must have a different name.
There are multiple ways to address the error. You could delete the existing track and then insert a new one or change the name of the new track before inserting it. |
forbidden (403) |
forbidden |
The permissions associated with the request are not sufficient to upload the caption track. The request might not be properly authorized. |
invalidValue (400) |
invalidMetadata |
The request contains invalid metadata values, which prevent the track from being created. Confirm that the request specifies valid values for the snippet.language , snippet.name , and snippet.videoId properties. The snippet.isDraft property can also be included, but it is not required. |
notFound (404) |
videoNotFound |
The video identified by the videoId parameter could not be found. |
captions.list
Error type | Error detail | Description |
---|---|---|
forbidden (403) |
forbidden |
One or more caption tracks could not be retrieved because the permissions associated with the request are not sufficient to retrieve the requested resources. The request might not be properly authorized. |
notFound (404) |
captionNotFound |
One or more of the specified caption tracks could not be found. This error occurs if the videoId parameter identifies an actual video, but the id parameter either identifies caption track IDs that do not exist or track IDs that are associated with other videos. Check the values of the request’s id and videoId parameters to ensure that they are correct. |
notFound (404) |
videoNotFound |
The video identified by the videoId parameter could not be found. |
captions.update
Error type | Error detail | Description |
---|---|---|
badRequest (400) |
contentRequired |
The request did not upload an updated caption file. The actual track contents are required if the sync parameter is set to true . |
forbidden (403) |
forbidden |
The permissions associated with the request are not sufficient to update the caption track. The request might not be properly authorized. |
notFound (404) |
captionNotFound |
The specified caption track could not be found. Check the value of the request’s id parameter to ensure that it is correct. |
channelSections
The following tables identify error messages that the API returns in response to calls related to channelSections
resources. These methods could also return errors listed in the Common errors section.
channelSections.delete
Error type | Error detail | Description |
---|---|---|
badRequest (400) |
notEditable |
This channel section cannot be deleted. |
forbidden (403) |
channelSectionForbidden |
The request is not properly authenticated or not supported for this channel. |
invalidValue (400) |
idInvalid |
The id property specifies an invalid channel section ID. |
invalidValue (400) |
idRequired |
The id property must specify a value that identifies the channel section being deleted. |
notFound (404) |
channelNotFound |
The channel is not found. |
notFound (404) |
channelSectionNotFound |
The channel section you are trying to update cannot be found. |
channelSections.insert
Error type | Error detail | Description |
---|---|---|
badRequest (400) |
defaultLanguageNotSetError |
The channelSection resource’s snippet.defaultLanguage property must be set to successfully insert or update the localizations object for that resource. |
badRequest (400) |
invalidLanguage |
One of the language keys of the localizations object failed validation. Use the channelSections.list method to retrieve valid values and update them following the guidelines in the a href="/youtube/v3/docs/channelSections#resource">channelSections resource documentation. |
badRequest (400) |
notEditable |
This channel section cannot be created. |
badRequest (400) |
styleRequired |
The channelSection resource must specify a value for the snippet.style field. |
badRequest (400) |
targetInvalidCountry |
One of the values in the targeting.countries list failed validation. Use the channelSections.list method to retrieve valid values and update them following the guidelines in the a href="/youtube/v3/docs/channelSections#resource">channelSections resource documentation. |
badRequest (400) |
targetInvalidLanguage |
One of the values in the targeting.languages list failed validation. Use the channelSections.list method to retrieve valid values and update them following the guidelines in the a href="/youtube/v3/docs/channelSections#resource">channelSections resource documentation. |
badRequest (400) |
targetInvalidRegion |
One of the values in the targeting.regions list failed validation. Use the channelSections.list method to retrieve valid values and update them following the guidelines in the a href="/youtube/v3/docs/channelSections#resource">channelSections resource documentation. |
badRequest (400) |
typeRequired |
The channelSection resource must specify a value for the snippet.type field. |
forbidden (403) |
channelSectionForbidden |
The request is not properly authenticated or is not supported for this channel. |
invalidValue (400) |
channelNotActive |
At least one of the specified channels is not active. |
invalidValue (400) |
channelsDuplicated |
The request failed because it specified duplicate channels. |
invalidValue (400) |
channelsNeeded |
If the snippet.type property has a value of multipleChannels , then the contentDetails.channels[] property must be specified and must specify at least one channel. |
invalidValue (400) |
channelsNotExpected |
The resource provided with the request specified a value for the contentDetails.channels[] property, but channels are not expected for this type of channel section. |
invalidValue (400) |
contentDetailsNeeded |
The resource you are inserting must contain a contentDetails object for this type of channel section. |
invalidValue (400) |
inValidPosition |
The snippet.position property contains an invalid value. |
invalidValue (400) |
maxChannelSectionExceeded |
The request cannot be completed because the channel already has the maximum number of channel sections. |
invalidValue (400) |
maxChannelsExceeded |
The request failed because it attempted to include too many channels in the channel section. |
invalidValue (400) |
maxPlaylistExceeded |
The request failed because it attempted to include too many playlists in the channel section. |
invalidValue (400) |
onePlaylistNeeded |
If the snippet.type property has a value of singlePlaylist , then the contentDetails.playlists[] property must specify exactly one playlist. |
invalidValue (400) |
ownChannelInChannels |
You cannot include your own channel in a channel section that appears on that channel. |
invalidValue (400) |
playlistIsPrivate |
One or more of the specified playlists are private and, therefore, cannot be included in the channel section. |
invalidValue (400) |
playlistsDuplicated |
The request failed because it specified duplicate playlists. |
invalidValue (400) |
playlistsNeeded |
If the snippet.type property has a value of singlePlaylist or multiplePlaylists , then the contentDetails.playlists[] property must be specified. |
invalidValue (400) |
playlistsNotExpected |
The resource provided with the request specified a value for the contentDetails.playlists[] property, but playlists are not expected for this type of channel section. |
invalidValue (400) |
snippetNeeded |
You must specify a snippet to create the channel section. |
invalidValue (400) |
titleLengthExceeded |
The value of the snippet.title property is too long. |
invalidValue (400) |
titleRequired |
If the snippet.type property has a value of multiplePlaylists or multipleChannels , then you must set the section’s title by specifying a value for the snippet.title property. |
notFound (404) |
channelNotFound |
One or more of the specified channels cannot be found. |
notFound (404) |
playlistNotFound |
One or more of the specified playlists cannot be found. |
channelSections.list
Error type | Error detail | Description |
---|---|---|
forbidden (403) |
channelSectionForbidden |
The requester is not allowed to access the requested channel sections. |
invalidValue (400) |
idInvalid |
The request specifies an invalid channel section ID. |
invalidValue (400) |
invalidCriteria |
The request could not be completed because the filter criteria are invalid. |
notFound (404) |
channelNotFound |
The channel associated with the request cannot be found. |
notFound (404) |
channelSectionNotFound |
The channel section associated with the request cannot be found. |
channelSections.update
Error type | Error detail | Description |
---|---|---|
badRequest (400) |
defaultLanguageNotSetError |
The channelSection resource’s snippet.defaultLanguage property must be set to successfully insert or update the localizations object for that resource. |
badRequest (400) |
invalidLanguage |
One of the language keys of the localizations object failed validation. Use the channelSections.list method to retrieve valid values and update them following the guidelines in the a href="/youtube/v3/docs/channelSections#resource">channelSections resource documentation. |
badRequest (400) |
notEditable |
This channel section cannot be edited. |
badRequest (400) |
styleRequired |
The channelSection resource must specify a value for the snippet.style field. |
badRequest (400) |
targetInvalidCountry |
One of the values in the targeting.countries list failed validation. Use the channelSections.list method to retrieve valid values and update them following the guidelines in the a href="/youtube/v3/docs/channelSections#resource">channelSections resource documentation. |
badRequest (400) |
targetInvalidLanguage |
One of the values in the targeting.languages list failed validation. Use the channelSections.list method to retrieve valid values and update them following the guidelines in the a href="/youtube/v3/docs/channelSections#resource">channelSections resource documentation. |
badRequest (400) |
targetInvalidRegion |
One of the values in the targeting.regions list failed validation. Use the channelSections.list method to retrieve valid values and update them following the guidelines in the a href="/youtube/v3/docs/channelSections#resource">channelSections resource documentation. |
badRequest (400) |
typeRequired |
The channelSection resource must specify a value for the snippet.type field. |
forbidden (403) |
channelSectionForbidden |
The request is not properly authenticated or is not supported for this channel. |
invalidValue (400) |
channelNotActive |
At least one of the specified channels is not active. |
invalidValue (400) |
channelsDuplicated |
The request failed because it specified duplicate channels. |
invalidValue (400) |
channelsNeeded |
If the snippet.type property has a value of multipleChannels , then the contentDetails.channels[] property must be specified and must specify at least one channel. |
invalidValue (400) |
channelsNotExpected |
The resource provided with the request specified a value for the contentDetails.channels[] property, but channels are not expected for this type of channel section. |
invalidValue (400) |
contentDetailsNeeded |
The resource you are updating must contain a contentDetails object for this type of channel section. |
invalidValue (400) |
idInvalid |
The id property specifies an invalid channel section ID. |
invalidValue (400) |
idRequired |
The id property must specify a value that identifies the channel section being updated. |
invalidValue (400) |
inValidPosition |
The snippet.position property contains an invalid value. |
invalidValue (400) |
maxChannelsExceeded |
The request failed because it attempted to include too many channels in the channel section. |
invalidValue (400) |
maxPlaylistExceeded |
The request failed because it attempted to include too many playlists in the channel section. |
invalidValue (400) |
onePlaylistNeeded |
If the snippet.type property has a value of singlePlaylist , then the contentDetails.playlists[] property must specify exactly one playlist. |
invalidValue (400) |
ownChannelInChannels |
You cannot include your own channel in a channel section that appears on that channel. |
invalidValue (400) |
playlistIsPrivate |
One or more of the specified playlists are private and, therefore, cannot be included in the channel section. |
invalidValue (400) |
playlistsDuplicated |
The request failed because it specified duplicate playlists. |
invalidValue (400) |
playlistsNeeded |
If the snippet.type property has a value of singlePlaylist or multiplePlaylists , then the contentDetails.playlists[] property must be specified. |
invalidValue (400) |
playlistsNotExpected |
The resource provided with the request specified a value for the contentDetails.playlists[] property, but playlists are not expected for this type of channel section. |
invalidValue (400) |
snippetNeeded |
You must specify a snippet to update the channel section. |
invalidValue (400) |
titleLengthExceeded |
The value of the snippet.title property is too long. |
invalidValue (400) |
titleRequired |
If the snippet.type property has a value of multiplePlaylists or multipleChannels , then you must set the section’s title by specifying a value for the snippet.title property. |
notFound (404) |
channelNotFound |
One or more of the specified channels cannot be found. |
notFound (404) |
channelSectionNotFound |
The channel section you are trying to update cannot be found. |
notFound (404) |
playlistNotFound |
One or more of the specified playlists cannot be found. |
channels
The following tables identify error messages that the API returns in response to calls related to channels
resources. These methods could also return errors listed in the Common errors section.
channels.list
Error type | Error detail | Description |
---|---|---|
badRequest (400) |
invalidCriteria |
A maximum of one of the following filters may be specified:id , mySubscribers , categoryId , mine , managedByMe , forUsername . In case of content owner authentication via the onBehalfOfContentOwner parameter, only the id or managedByMe may be specified. |
forbidden (403) |
channelForbidden |
The channel specified by the id parameter does not support the request or the request is not properly authorized. |
notFound (404) |
categoryNotFound |
The category identified by the categoryId parameter cannot be found. Use the guideCategories.list method to retrieve a list of valid values. |
notFound (404) |
channelNotFound |
The channel specified in the id parameter cannot be found. |
channels.update
Error type | Error detail | Description |
---|---|---|
badRequest (400) |
brandingValidationError |
One of the values in the brandingSettings object failed validation. Use the channels.list method to retrieve the existing settings for the channel, and update the property values following the guidelines in the channels resource documentation. |
badRequest (400) |
channelTitleUpdateForbidden |
When updating a channel’s brandingSettings part , you must set the brandingSettings.channel.title property’s value to the channel’s current title or omit the property. The API returns an error if you change the property’s value. |
badRequest (400) |
defaultLanguageNotSetError |
The defaultLanguage must be set to update localizations . |
badRequest (400) |
invalidBrandingOption |
One of the branding settings that you specified does not exist. Use the channels.list method to retrieve valid values and make sure to update them following the guidelines in the channels resource documentation. |
badRequest (400) |
invalidCustomMessage |
The request metadata specifies an invalid custom message. Check the value of the invideoPromotion.items[].customMessage property in the resource that the request sent. |
badRequest (400) |
invalidDuration |
The request metadata specifies an invalid duration in the invideoPromotion part. |
badRequest (400) |
invalidDuration |
The request metadata specifies an invalid position type for determining how the promoted item is positioned in the video player. Check the value of the invideoPromotion.position.type property in the resource that the request sent. |
badRequest (400) |
invalidRecentlyUploadedBy |
The request metadata specifies an invalid channel ID. Check the value of the invideoPromotion.items[].id.recentlyUploadedBy property in the resource that the request sent. |
badRequest (400) |
invalidTimingOffset |
The request metadata specifies an invalid timing offset in the invideoPromotion part. |
badRequest (400) |
invalidTimingOffset |
The request metadata specifies an invalid timing offset for determining when the promoted item should be displayed in the video player. Check the value of the invideoPromotion.timing.offsetMs property in the resource that the request sent. |
badRequest (400) |
invalidTimingType |
The request metadata specifies an invalid timing method for determining when the promoted item should be displayed in the video player. Check the value of the invideoPromotion.timing.type property in the resource that the request sent. |
badRequest (400) |
localizationValidationError |
One of the values in the localizations object failed validation. Use the channels.list method to retrieve valid values and make sure to update them following the guidelines in the channels resource documentation. |
badRequest (400) |
tooManyPromotedItems |
Number of allowed promoted items exceeded in the invideoPromotion part. |
forbidden (403) |
channelForbidden |
The channel specified in the id parameter does not support the request or the request is not properly authorized. |
forbidden (403) |
promotedVideoNotAllowed |
The channel that the API request is attempting to update cannot be found. Check the value of the id property in the channel resource that the request sent to ensure that the channel ID is correct. |
forbidden (403) |
websiteLinkNotAllowed |
The specified website url is not allowed. |
notFound (404) |
channelNotFound |
The channel specified by the id parameter cannot be found or does not have branding options. |
notFound (404) |
channelNotFound |
The channel specified in the id parameter cannot be found. |
notFound (404) |
unknownChannelId |
The specified channel ID was not found. |
notFound (404) |
unknownChannelId |
The specified recentlyUploadedBy channel ID was not found. |
notFound (404) |
unknownVideoId |
The video ID specified as a promoted item cannot be found. |
required (400) |
requiredItemIdType |
The request metadata must specify an item type in the invideoPromotion part. |
required (400) |
requiredItemId |
The request metadata must specify an item id the invideoPromotion part. |
required (400) |
requiredTimingOffset |
The request metadata must specify a default timing offset so that YouTube can determine when to display the promoted item. Set the value of the invideoPromotion.defaultTiming.offsetMs property in the resource that the request sends. |
required (400) |
requiredTimingOffset |
The request metadata must specify a timing offset so that YouTube can determine when to display the promoted item. Set the value of the invideoPromotion.timing.offsetMs property in the resource that the request sends. |
required (400) |
requiredTimingType |
The request metadata must specify a timing method so that YouTube can determine when to display the promoted item. Set the value of the invideoPromotion.defaultTiming.type property in the resource that the request sends. |
required (400) |
requiredTimingType |
The request metadata must specify a timing method so that YouTube can determine when to display the promoted item. Set the value of the invideoPromotion.timing.type property in the resource that the request sends. |
required (400) |
requiredTiming |
The request metadata must specify a timing for each item in the invideoPromotion part. |
required (400) |
requiredVideoId |
The request metadata must specify a video ID to identify the promoted item. |
required (400) |
requiredWebsiteUrl |
The request metadata must specify a website url in the invideoPromotion part. Set the value of the invideoPromotion.items[].id.websiteUrl property in the resource that the request sends. |
members
The following tables identify error messages that the API returns in response to calls related to members
resources. These methods could also return errors listed in the Common errors section.
members.list
Error type | Error detail | Description |
---|---|---|
badRequest (400) |
channelMembershipsNotEnabled |
The creator channel authorizing the request does not have channel memberships enabled. |
badRequest (400) |
invalidMode |
The mode parameter value is invalid.This error might occur if the pageToken parameterspecifies a token that was retrieved using a different mode than the one specified. |
badRequest (400) |
invalidPageToken |
The pageToken parameter value isinvalid. This error occurs if the page token used in the request has expired. |
badRequest (400) |
invalidHasAccessToLevel |
The hasAccessToLevel parameter value is invalid. There is no level with the specified id . |
badRequest (400) |
invalidFilterByMemberChannelId |
The filterByMemberChannelId parameter value is invalid. This error occurs if the filterByMemberChannelId parameter valuespecifies more than 100 channels. |
membershipsLevels
The following tables identify error messages that the API returns in response to calls related to members
resources. These methods could also return errors listed in the Common errors section.
membershipsLevels.list
Error type | Error detail | Description |
---|---|---|
badRequest (400) |
channelMembershipsNotEnabled |
The creator channel authorizing the request does not have channel memberships enabled. |
playlistItems
The following tables identify error messages that the API returns in response to calls related to playlistItems
resources. These methods could also return errors listed in the Common errors section.
playlistItems.delete
Error type | Error detail | Description |
---|---|---|
forbidden (403) |
playlistItemsNotAccessible |
The request is not properly authorized to delete the specified playlist item. |
notFound (404) |
playlistItemNotFound |
The playlist item identified with the request’s id parameter cannot be found. |
invalidValue (400) |
playlistOperationUnsupported |
The API does not support the ability to delete videos from the specified playlist. For example, you can’t delete a video from your uploaded videos playlist. |
playlistItems.insert
Error type | Error detail | Description |
---|---|---|
duplicate |
videoAlreadyInPlaylist |
The video that you are trying to add to the playlist is already in the playlist. |
forbidden (403) |
playlistContainsMaximumNumberOfVideos |
The playlist already contains the maximum allowed number of items. |
forbidden (403) |
playlistItemsNotAccessible |
The request is not properly authorized to insert the specified playlist item. |
invalidValue (400) |
invalidContentDetails |
The contentDetails property in the request is not valid. A possible reason is that contentDetails.note field is longer than 280 characters. |
invalidValue (400) |
invalidPlaylistItemPosition |
The request attempts to set the playlist item’s position to an invalid or unsupported value. Check the value of the position property in the resource’s snippet . |
invalidValue (400) |
invalidResourceType |
The type specified for the resource ID is not supported for this operation. The resource ID identifies the item being added to the playlist – e.g. youtube#video . |
invalidValue (400) |
manualSortRequired |
The request attempts to set the playlist item’s position, but the playlist does not use manual sorting. (For example, playlist items might be sorted by date or popularity.) You can address the error by removing the snippet.position element from the resource that the request is inserting. If you want the playlist item to have a particular position in the list, you need to first update the playlist’s Ordering option to Manual in the playlist’s settings. This settings can be adjusted in the YouTube Video Manager. |
invalidValue (400) |
videoAlreadyInAnotherSeriesPlaylist |
The video that you are trying to add to the playlist is already in another series playlist. |
invalidValue (400) |
playlistOperationUnsupported |
The API does not support the ability to insert videos into the specified playlist. For example, you can’t insert a video into your uploaded videos playlist. |
notFound (404) |
playlistNotFound |
The playlist identified with the request’s playlistId parameter cannot be found. |
notFound (404) |
videoNotFound |
The video that you are trying to add to the playlist cannot be found. Check the value of the videoId property to ensure that it is correct. |
required (400) |
channelIdRequired |
The request does not specify a value for the required channelId property. |
required (400) |
playlistIdRequired |
The request does not specify a value for the required playlistId property. |
required (400) |
resourceIdRequired |
The request must contain a resource in which the snippet object specifies a resourceId . |
playlistItems.list
Error type | Error detail | Description |
---|---|---|
forbidden (403) |
playlistItemsNotAccessible |
The request is not properly authorized to retrieve the specified playlist. |
notFound (404) |
playlistNotFound |
The playlist identified with the request’s playlistId parameter cannot be found. |
notFound (404) |
videoNotFound |
The video identified with the request’s videoId parameter cannot be found. |
required (400) |
playlistIdRequired |
The subscribe request does not specify a value for the required playlistId property. |
invalidValue (400) |
playlistOperationUnsupported |
The API does not support the ability to list videos in the specified playlist. For example, you can’t list a video in your watch later playlist. |
playlistItems.update
Error type | Error detail | Description |
---|---|---|
forbidden (403) |
playlistItemsNotAccessible |
The request is not properly authorized to update the specified playlist item. |
invalidValue (400) |
invalidPlaylistItemPosition |
The request attempts to set the playlist item’s position to an invalid or unsupported value. Check the value of the position property in the resource’s snippet . |
invalidValue (400) |
invalidResourceType |
The type specified for the resource ID is not supported for this operation. The resource ID identifies the item being added to the playlist – e.g. youtube#video . |
invalidValue (400) |
invalidSnippet |
The request does not specify a valid snippet property. |
invalidValue (400) |
manualSortRequired |
The request attempts to set the playlist item’s position, but the playlist does not use manual sorting. (For example, playlist items might be sorted by date or popularity.) You can address the error by removing the snippet.position element from the resource that the request is inserting. If you want the playlist item to have a particular position in the list, you need to first update the playlist’s Ordering option to Manual in the playlist’s settings. This settings can be adjusted in the YouTube Video Manager. |
invalidValue (400) |
playlistOperationUnsupported |
The API does not support the ability to update videos in the specified playlist. For example, you can’t update a video in your uploaded videos playlist. |
notFound (404) |
playlistItemNotFound |
The playlist item identified with the request’s id property cannot be found. |
notFound (404) |
playlistNotFound |
The playlist identified with the request’s playlistId parameter cannot be found. |
required (400) |
channelIdRequired |
The request does not specify a value for the required channelId property. |
required (400) |
playlistIdRequired |
The request does not specify a value for the required playlistId property. |
required (400) |
playlistItemIdRequired |
The playlist item resource specified in the request must use the id property to identify the playlist item that is being updated. |
playlists
The following tables identify error messages that the API returns in response to calls related to playlists
resources. These methods could also return errors listed in the Common errors section.
playlists.delete
Error type | Error detail | Description |
---|---|---|
forbidden (403) |
playlistForbidden |
This operation is forbidden or the request is not properly authorized. |
notFound (404) |
playlistNotFound |
The playlist identified with the request’s id parameter cannot be found. |
invalidValue (400) |
playlistOperationUnsupported |
The API does not support the ability to delete the specified playlist. For example, you can’t delete your uploaded videos playlist. |
playlists.list
Error type | Error detail | Description |
---|---|---|
forbidden (403) |
channelClosed |
The channel specified in the channelId parameter has been closed. |
forbidden (403) |
channelSuspended |
The channel specified in the channelId parameter has been suspended. |
forbidden (403) |
playlistForbidden |
The playlist identified with the request’s id parameter does not support the request or the request is not properly authorized. |
notFound (404) |
channelNotFound |
The channel specified in the channelId parameter cannot be found. |
notFound (404) |
playlistNotFound |
The playlist identified with the request’s id parameter cannot be found. |
invalidValue (400) |
playlistOperationUnsupported |
The API does not support the ability to list the specified playlist. For example, you can’t list your watch later playlist. |
playlists.insert
Error type | Error detail | Description |
---|---|---|
badRequest (400) |
defaultLanguageNotSetError |
The defaultLanguage must be set to update localizations . |
badRequest (400) |
localizationValidationError |
One of the values in the localizations object failed validation. Use the playlists.list method to retrieve valid values and make sure to update them following the guidelines in the playlists resource documentation. |
badRequest (400) |
maxPlaylistExceeded |
The playlist cannot be created because the channel already has the maximum number of playlists allowed. |
forbidden (403) |
playlistForbidden |
This operation is forbidden or the request is not properly authorized. |
invalidValue (400) |
invalidPlaylistSnippet |
The request provides an invalid playlist snippet. |
required (400) |
playlistTitleRequired |
The request must specify a playlist title. |
playlists.update
Error type | Error detail | Description |
---|---|---|
badRequest (400) |
defaultLanguageNotSetError |
The defaultLanguage must be set to update localizations . |
badRequest (400) |
localizationValidationError |
One of the values in the localizations object failed validation. Use the playlists.list method to retrieve valid values and make sure to update them following the guidelines in the playlists resource documentation. |
forbidden (403) |
playlistForbidden |
This operation is forbidden or the request is not properly authorized. |
invalidValue (400) |
invalidPlaylistSnippet |
The request provides an invalid playlist snippet. |
invalidValue (400) |
playlistOperationUnsupported |
The API does not support the ability to update the specified playlist. For example, you can’t update the properties of your uploaded videos playlist. |
notFound (404) |
playlistNotFound |
The playlist identified with the request’s id parameter cannot be found. |
required (400) |
playlistTitleRequired |
The request must specify a playlist title. |
search
The following tables identify error messages that the API returns in response to calls related to search
resources. These methods could also return errors listed in the Common errors section.
search.list
Error type | Error detail | Description |
---|---|---|
badRequest (400) |
invalidChannelId |
The channelId parameter specified an invalid channel ID. |
badRequest (400) |
invalidLocation |
The location and/or locationRadius parameter value was formatted incorrectly. |
badRequest (400) |
invalidRelevanceLanguage |
The relevanceLanguage parameter value was formatted incorrectly. |
badRequest (400) |
invalidSearchFilter |
The request contains an invalid combination of search filters and/or restrictions. Note that you must set the type parameter to video if you set a value for the eventType , videoCaption , videoCategoryId , videoDefinition , videoDimension , videoDuration , videoEmbeddable , videoLicense , videoSyndicated , or videoType parameters. |
badRequest (400) |
invalidVideoId |
The relatedToVideo parameter specified an invalid video ID. |
subscriptions
The following tables identify error messages that the API returns in response to calls related to subscriptions
resources. These methods could also return errors listed in the Common errors section.
subscriptions.delete
Error type | Error detail | Description |
---|---|---|
forbidden (403) |
subscriptionForbidden |
The request is not properly authenticated or not supported for this channel. |
notFound (404) |
subscriptionNotFound |
The subscription that you are trying to delete cannot be found. Check the value of the request’s id parameter to ensure that it is correct. |
subscriptions.insert
Error type | Error detail | Description |
---|---|---|
badRequest (400) |
subscriptionDuplicate |
The subscription that you are trying to create already exists. |
badRequest (400) |
subscriptionForbidden |
You have reached your maximum number of subscriptions. |
badRequest (400) |
subscriptionForbidden |
Too many recent subscriptions. Please try again in a few hours. |
badRequest (400) |
subscriptionForbidden |
Subscribing to your own channel is not supported. |
forbidden (403) |
subscriptionForbidden |
The request is not properly authenticated or not supported for this channel. |
notFound (404) |
publisherNotFound |
The resource specified by the request’s snippet.resourceId property cannot be found. |
notFound (404) |
subscriberNotFound |
The subscriber identified with the request cannot be found. |
required (400) |
publisherRequired |
The subscription resource specified in the request must use the snippet.resourceId property to identify the channel that is being subscribed to. |
subscriptions.list
Error type | Error detail | Description |
---|---|---|
forbidden (403) |
accountClosed |
Subscriptions could not be retrieved because the subscriber’s account is closed. |
forbidden (403) |
accountSuspended |
Subscriptions could not be retrieved because the subscriber’s account is suspended. |
forbidden (403) |
subscriptionForbidden |
The requester is not allowed to access the requested subscriptions. |
notFound (404) |
subscriberNotFound |
The subscriber identified with the request cannot be found. |
thumbnails
The following tables identify error messages that the API returns in response to calls related to thumbnails
resources. These methods could also return errors listed in the Common errors section.
thumbnails.set
Error type | Error detail | Description |
---|---|---|
badRequest (400) |
invalidImage |
The provided image content is invalid. |
badRequest (400) |
mediaBodyRequired |
The request does not include the image content. |
forbidden (403) |
forbidden |
The thumbnail can’t be set for the specified video. The request might not be properly authorized. |
forbidden (403) |
forbidden |
The authenticated user doesn’t have permissions to upload and set custom video thumbnails. |
notFound (404) |
videoNotFound |
The video that you are trying to insert a thumbnail image for cannot be found. Check the value of the request’s videoId parameter to ensure that it is correct. |
videoAbuseReportReasons
The following tables identify error messages that the API returns in response to calls related to videoAbuseReportReasons
resources. These methods could also return errors listed in the Common errors section.
videoAbuseReportReasons.list
Error type | Error detail | Description |
---|---|---|
forbidden (403) |
forbidden |
Access forbidden. The request may not be properly authorized. |
videoCategories
The following tables identify error messages that the API returns in response to calls related to videoCategories
resources. These methods could also return errors listed in the Common errors section.
videoCategories.list
Error type | Error detail | Description |
---|---|---|
notFound (404) |
videoCategoryNotFound |
The video category identified by the id parameter cannot be found. Use the videoCategories.list method to retrieve a list of valid values. |
videos
The following tables identify error messages that the API returns in response to calls related to videos
resources. These methods could also return errors listed in the Common errors section.
videos.insert
Error type | Error detail | Description |
---|---|---|
badRequest (400) |
defaultLanguageNotSet |
The request is trying to add localized video details without specifying the default language of the video details. |
badRequest (400) |
invalidCategoryId |
The snippet.categoryId property specifies an invalid category ID. Use the videoCategories.list method to retrieve supported categories. |
badRequest (400) |
invalidDescription |
The request metadata specifies an invalid video description. |
badRequest (400) |
invalidFilename |
The video filename specified in the Slug header is invalid. |
badRequest (400) |
invalidPublishAt |
The request metadata specifies an invalid scheduled publishing time. |
badRequest (400) |
invalidRecordingDetails |
The recordingDetails object in the request metadata specifies invalid recording details. |
badRequest (400) |
invalidTags |
The request metadata specifies invalid video keywords. |
badRequest (400) |
invalidTitle |
The request metadata specifies an invalid or empty video title. |
badRequest (400) |
invalidVideoGameRating |
The request metadata specifies an invalid video game rating. |
badRequest (400) |
invalidVideoMetadata |
The request metadata is invalid. This error occurs if the request updates the snippet part of a video resource but does not set a value for both the snippet.title and snippet.categoryId properties. |
badRequest (400) |
mediaBodyRequired |
The request does not include the video content. |
badRequest (400) |
uploadLimitExceeded |
The user has exceeded the number of videos they may upload. |
forbidden (403) |
forbidden |
|
forbidden (403) |
forbiddenLicenseSetting |
The request attempts to set an invalid license for the video. |
forbidden (403) |
forbiddenPrivacySetting |
The request attempts to set an invalid privacy setting for the video. |
videos.list
Error type | Error detail | Description |
---|---|---|
badRequest (400) |
videoChartNotFound |
The requested video chart is not supported or is not available. |
forbidden (403) |
forbidden |
The request is not properly authorized to access video file or processing information. Note that the fileDetails , processingDetails , and suggestions parts are only available to that video’s owner. |
forbidden (403) |
forbidden |
The request cannot access user rating information. This error may occur because the request is not properly authorized to use the myRating parameter. |
notFound (404) |
videoNotFound |
The video that you are trying to retrieve cannot be found. Check the value of the request’s id parameter to ensure that it is correct. |
videos.delete
Error type | Error detail | Description |
---|---|---|
forbidden (403) |
forbidden |
The video that you are trying to delete cannot be deleted. The request might not be properly authorized. |
notFound (404) |
videoNotFound |
The video that you are trying to delete cannot be found. Check the value of the request’s id parameter to ensure that it is correct. |
videos.update
Error type | Error detail | Description |
---|---|---|
badRequest (400) |
defaultLanguageNotSet |
The API request is trying to add localized video details without specifying the default language of the video details. |
badRequest (400) |
invalidCategoryId |
The snippet.categoryId property specifies an invalid category ID. Use the videoCategories.list method to retrieve supported categories. |
badRequest (400) |
invalidDefaultBroadcastPrivacySetting |
The request attempts to set an invalid privacy setting for the default broadcast. |
badRequest (400) |
invalidDescription |
The request metadata specifies an invalid video description. |
badRequest (400) |
invalidPublishAt |
The request metadata specifies an invalid scheduled publishing time. |
badRequest (400) |
invalidRecordingDetails |
The recordingDetails object in the request metadata specifies invalid recording details. |
badRequest (400) |
invalidTags |
The request metadata specifies invalid video keywords. |
badRequest (400) |
invalidTitle |
The request metadata specifies an invalid or empty video title. |
badRequest (400) |
invalidVideoMetadata |
The request metadata is invalid. This error occurs if the request updates the snippet part of a video resource but does not set a value for both the snippet.title and snippet.categoryId properties. |
forbidden (403) |
forbidden |
Access forbidden. The request may not be properly authorized. |
forbidden (403) |
forbiddenEmbedSetting |
The request attempts to set an invalid embed setting for the video. Note that some channels may not have permission to offer embedded players for live streams. See the YouTube Help Center for more information. |
forbidden (403) |
forbiddenLicenseSetting |
The request attempts to set an invalid license for the video. |
forbidden (403) |
forbiddenPrivacySetting |
The request attempts to set an invalid privacy setting for the video. |
notFound (404) |
videoNotFound |
The video that you are trying to update cannot be found. Check the value of the id field in the request body to ensure that it is correct. |
videos.rate
Error type | Error detail | Description |
---|---|---|
badRequest (400) |
emailNotVerified |
The user must verify their e-mail address prior to rating. |
badRequest (400) |
invalidRating |
The request contained an unexpected value for the rating parameter. |
badRequest (400) |
videoPurchaseRequired |
Rental videos can only be rated by users who rented them. |
forbidden (403) |
forbidden |
The video that you are trying to rate cannot be rated. The request might not be properly authorized. |
forbidden (403) |
videoRatingDisabled |
The owner of the video that you are trying to rate has disabled ratings for that video. |
notFound (404) |
videoNotFound |
The video that you are trying to rate cannot be found. Check the value of the request’s id parameter to ensure that it is correct. |
videos.reportAbuse
Error type | Error detail | Description |
---|---|---|
badRequest (400) |
invalidAbuseReason |
The request contained an unexpected value for the reason_id field, or a combination of the reason_id and secondary_reason_id fields. |
badRequest (400) |
rateLimitExceeded |
The user has sent too many requests in a given timeframe. |
forbidden (403) |
forbidden |
|
notFound (404) |
videoNotFound |
The video that you are trying to report abuse for cannot be found. |
watermarks
The following tables identify error messages that the API returns in response to calls related to watermarks
resources. These methods could also return errors listed in the Common errors section.
watermarks.set
Error type | Error detail | Description |
---|---|---|
badRequest (400) |
imageFormatUnsupported |
The image you provided is in an unsupported format. |
badRequest (400) |
imageTooTall |
The image you provided is too tall. |
badRequest (400) |
imageTooWide |
The image you provided is too wide. |
badRequest (400) |
mediaBodyRequired |
The request does not include the image content. |
forbidden (403) |
forbidden |
The watermark can’t be set for the specified channel. The request may not be properly authorized, or the channelId parameter is set to an invalid value. |
watermarks.unset
Error type | Error detail | Description |
---|---|---|
forbidden (403) |
forbidden |
The watermark can’t be unset for the specified channel. The request may not be properly authorized, or the channelId parameter is set to an invalid value. |
This document identifies the different types of errors that YouTube Live Streaming API operations can return. You can also find a list of errors for any individual method in the reference documentation for that method.
fanFundingEvents
The following tables identify error messages that the API returns in response to calls related to fanFundingEvents
resources.
fanFundingEvents.list
Error type | Error detail | Description |
---|---|---|
forbidden (403) |
insufficientPermissions |
You do not have the necessary permissions to view the channel’s Fan Funding events. |
invalidValue (400) |
fanFundingNotEnabledForChannelId |
The channel does not have Fan Funding enabled. |
liveBroadcasts
The following tables identify error messages that the API returns in response to calls related to liveBroadcasts
resources.
liveBroadcasts.bind
Error type | Error detail | Description |
---|---|---|
backendError |
internalError |
An internal error occurred during the bind. |
forbidden (403) |
liveBroadcastBindingNotAllowed |
The current status of the live broadcast does not allow it to be bound to a stream. |
insufficientPermissions |
insufficientLivePermissions |
The request is not authorized to retrieve the specified live broadcast. For more information, see Implementing OAuth2 authentication. |
insufficientPermissions |
liveStreamingNotEnabled |
The user that authorized the request is not enabled to stream live video on YouTube. The user can find more information at https://www.youtube.com/features. |
notFound (404) |
liveBroadcastNotFound |
The broadcast specified by the id parameter does not exist. |
notFound (404) |
liveStreamNotFound |
The stream specified by the streamId parameter does not exist. |
rateLimitExceeded |
userRequestsExceedRateLimit |
The user has sent too many requests in a given timeframe. |
required (400) |
idRequired |
The required id parameter must identify the broadcast to bind. |
liveBroadcasts.delete
Error type | Error detail | Description |
---|---|---|
forbidden (403) |
liveBroadcastDeletionNotAllowed |
The current status of the live broadcast does not allow it to be deleted. |
insufficientPermissions |
insufficientLivePermissions |
The request is not authorized to delete the specified live broadcast. For more information, see Implementing OAuth2 authentication. |
insufficientPermissions |
liveStreamingNotEnabled |
The user that authorized the request is not enabled to stream live video on YouTube. The user can find more information at https://www.youtube.com/features. |
notFound (404) |
liveBroadcastNotFound |
The id property specified in the liveBroadcast resource did not identify a broadcast. |
liveBroadcasts.insert
Error type | Error detail | Description |
---|---|---|
insufficientPermissions |
insufficientLivePermissions |
The request is not authorized to create the live broadcast. |
insufficientPermissions |
livePermissionBlocked |
The user that authorized the request is unable to stream live video on YouTube at this time. Details explaining why the user cannot stream live video may be available in the user’s channel settings at https://www.youtube.com/features. |
insufficientPermissions |
liveStreamingNotEnabled |
The user that authorized the request is not enabled to stream live video on YouTube. The user can find more information at https://www.youtube.com/features. |
invalidValue (400) |
invalidAutoStart |
The liveBroadcast resource contained an invalid value for the contentDetails.enableAutoStart property.Not all broadcasts support this setting. |
invalidValue (400) |
invalidAutoStop |
The liveBroadcast resource contained an invalid value for the contentDetails.enableAutoStop property. Youcannot modify the enableAutoStop setting for a persistent broadcast. |
invalidValue (400) |
invalidDescription |
The liveBroadcast resource did not specify a valid value for the snippet.description property. The property’s value can contain up to 5000 characters. |
invalidValue (400) |
invalidEmbedSetting |
The liveBroadcast resource contained an invalid value for the contentDetails.enable_embed property. You cannot embed this broadcast. |
invalidValue (400) |
invalidLatencyPreferenceOptions |
The liveBroadcast resource contained an invalid value for the contentDetails.latencyPreference property.Not all settings are supported with this latency preference. |
invalidValue (400) |
invalidPrivacyStatus |
The liveBroadcast resource contained an invalid value for the status.privacy_status property. |
invalidValue (400) |
invalidProjection |
The liveBroadcast resource contained an invalid value for the contentDetails.projection property. A default broadcast’s projection cannot be set to 360 . |
invalidValue (400) |
invalidScheduledEndTime |
The liveBroadcast resource contained an invalid value for the snippet.scheduledEndTime property. The scheduled end time must follow the scheduled start time. |
invalidValue (400) |
invalidScheduledStartTime |
The liveBroadcast resource contained an invalid value for the snippet.scheduledStartTime property. The scheduled start time must be in the future and close enough to the current date that a broadcast could be reliably scheduled at that time. |
invalidValue (400) |
invalidTitle |
The liveBroadcast resource did not specify a valid value for the snippet.title property. The property’s value must be between 1 and 100 characters long. |
limitExceeded |
userBroadcastsExceedLimit |
The user has created too many live or scheduled broadcasts and must stop or delete some. |
rateLimitExceeded |
userRequestsExceedRateLimit |
The user has sent too many requests in a given timeframe. |
required (400) |
privacyStatusRequired |
The liveBroadcast resource must specify a privacy status. See valid privacyStatus values. |
required (400) |
scheduledEndTimeRequired |
The liveBroadcast resource must specify the snippet.scheduledEndTime property. |
required (400) |
scheduledStartTimeRequired |
The liveBroadcast resource must specify the snippet.scheduledStartTime property. |
required (400) |
titleRequired |
The liveBroadcast resource must specify the snippet.title property. |
liveBroadcasts.list
Error type | Error detail | Description |
---|---|---|
insufficientPermissions |
insufficientLivePermissions |
The request is not authorized to retrieve the live broadcast. |
insufficientPermissions |
liveStreamingNotEnabled |
The user that authorized the request is not enabled to stream live video on YouTube. The user can find more information at https://www.youtube.com/features. |
liveBroadcasts.transition
Error type | Error detail | Description |
---|---|---|
backendError |
errorExecutingTransition |
An error occurred while changing the broadcast’s status. |
forbidden (403) |
errorStreamInactive |
The requested transition is not allowed when the stream that is bound to the broadcast is inactive. |
forbidden (403) |
invalidTransition |
The live broadcast can’t transition from its current status to the requested status. |
forbidden (403) |
redundantTransition |
The live broadcast is already in the requested status or processing to the requested status. |
insufficientPermissions |
insufficientLivePermissions |
The request is not authorized to transition the live broadcast. |
insufficientPermissions |
livePermissionBlocked |
The user that authorized the request is unable to stream live video on YouTube at this time. Details explaining why the user cannot stream live video may be available in the user’s channel settings at https://www.youtube.com/features. |
insufficientPermissions |
liveStreamingNotEnabled |
The user that authorized the request is not enabled to stream live video on YouTube. The user can find more information at https://www.youtube.com/features. |
notFound (404) |
liveBroadcastNotFound |
The broadcast specified by the id parameter does not exist. |
rateLimitExceeded (403) |
userRequestsExceedRateLimit |
The user has sent too many requests in a given timeframe. |
required (400) |
idRequired |
The required id parameter must identify the broadcast whose status you want to transition. |
required (400) |
statusRequired |
The API request must specify a value for the status parameter. |
liveBroadcasts.update
Error type | Error detail | Description |
---|---|---|
forbidden (403) |
closedCaptionsTypeModificationNotAllowed |
The contentDetails.closedCaptionsType value can only be modified when the broadcast is in the created or ready status. |
forbidden (403) |
enableAutoStartModificationNotAllowed |
The contentDetails.enableAutoStart value can only be modified when the stream is inactive and the broadcast is in the created or ready status. |
forbidden (403) |
enableClosedCaptionsModificationNotAllowed |
The contentDetails.enableClosedCaptions value can only be modified when the broadcast’s status is created or ready . |
forbidden (403) |
enableDvrModificationNotAllowed |
The contentDetails.enableDvr value can be modified only when the broadcast’s status is created or ready . |
forbidden (403) |
enableMonitorStreamModificationNotAllowed |
The contentDetails.monitorStream.enableMonitorStream value can be modified only when the broadcast’s status is created or ready . |
forbidden (403) |
recordFromStartModificationNotAllowed |
The contentDetails.recordFromStart value can be modified only when the broadcast’s status is created or ready . |
insufficientPermissions |
insufficientLivePermissions |
The request is not authorized to update the specified live broadcast. For more information, see Implementing OAuth2 authentication. |
insufficientPermissions |
liveStreamingNotEnabled |
The user that authorized the request is not enabled to stream live video on YouTube. The user can find more information at https://www.youtube.com/features. |
invalidValue (400) |
invalidAutoStart |
The liveBroadcast resource contained an invalid value for the contentDetails.enableAutoStart property.You cannot modify the enableAutoStart setting for a persistent broadcast. |
invalidValue (400) |
invalidAutoStop |
The liveBroadcast resource contained an invalid value for the contentDetails.enableAutoStop property. Youcannot modify the enableAutoStop setting for a persistent broadcast. |
invalidValue (400) |
invalidDescription |
The liveBroadcast resource did not specify a valid value for the snippet.description property. snippet.description can contain up to 5000 characters. |
invalidValue (400) |
invalidEmbedSetting |
The liveBroadcast resource contained an invalid value for the contentDetails.enable_embed property. You cannot embed this broadcast. |
invalidValue (400) |
invalidEnableClosedCaptions |
In the liveBroadcast resource, the value of the contentDetails.enableClosedCaptions property is incompatible with the value of the contentDetails.closedCaptionType setting. Modify the resource to only include one of the two properties, and then resubmit the request. |
invalidValue (400) |
invalidLatencyPreferenceOptions |
The liveBroadcast resource contained an invalid value for the contentDetails.latencyPreference property.Not all settings are supported with this latency preference. |
invalidValue (400) |
invalidPrivacyStatus |
The liveBroadcast resource did not specify a valid privacy status. See valid privacyStatus values. |
invalidValue (400) |
invalidProjection |
The liveBroadcast resource contained an invalid value for the contentDetails.projection property. A persistent broadcast’s projection cannot be set to 360. |
invalidValue (400) |
invalidScheduledEndTime |
The liveBroadcast resource contained an invalid value for the snippet.scheduledEndTime property. The scheduled end time must follow the scheduled start time. |
invalidValue (400) |
invalidScheduledStartTime |
The liveBroadcast resource contained an invalid value for the snippet.scheduledStartTime property. The scheduled start time must be in the future. |
invalidValue (400) |
invalidTitle |
The liveBroadcast resource did not specify a valid value for the snippet.title property. snippet.title must be between 1 and 100 characters long. |
notFound (404) |
liveBroadcastNotFound |
The id property specified in the liveBroadcast resource did not identify a broadcast. |
required (400) |
broadcastStreamDelayMsRequired |
The liveBroadcast resource did not specify the contentDetails.monitorStream.broadcastStreamDelayMs property. |
required (400) |
enableMonitorStreamRequired |
The liveBroadcast resource did not specify the contentDetails.monitorStream.enableMonitorStream property. |
required (400) |
idRequired |
The liveBroadcast resource must include and specify a value for the id property. |
required (400) |
privacyStatusRequired |
The liveBroadcast resource did not specify a privacy status. See for valid privacyStatus values. |
required (400) |
scheduledEndTimeRequired |
The liveBroadcast resource did not specify the snippet.scheduledEndTime property. |
required (400) |
scheduledStartTimeRequired |
The liveBroadcast resource did not specify the snippet.scheduledStartTime property. |
required (400) |
titleRequired |
The liveBroadcast resource did not specify the snippet.title property. |
liveBroadcasts.cuepoint
Error type | Error detail | Description |
---|---|---|
insufficientPermissions (403) |
insufficientLivePermissions |
The request is not authorized to insert a cuepoint in the live broadcast. |
insufficientPermissions (403) |
liveStreamingNotEnabled |
The user that authorized the request is not enabled to stream live video on YouTube. The user can find more information at https://support.google.com/youtube/answer/2474026 and https://www.youtube.com/features. |
rateLimitExceeded (403) |
userRequestsExceedRateLimit |
The user has sent too many requests in a given timeframe. |
required (400) |
idRequired |
The required id parameter must identify the broadcastin which you want to insert a cuepoint. |
required (400) |
cueTypeRequired |
The required cueType field must be specified in theAPI request body. |
notFound (404) |
liveBroadcastNotFound |
The broadcast specified by the id parameter does not exist. |
invalidValue (400) |
conflictingTimeFields |
Only one of insertionOffsetTimeMs andwalltimeMs may be specified. Setting both values causes an error. If you donot set either value, YouTube will use the default insertionOffsetTimeMs time( 0 ), which means that the cuepoint will be inserted as soon as possible. |
invalidValue (400) |
invalidInsertionOffsetTimeMs |
The cuepoint resource specified an invalid value for theinsertionOffsetTimeMs property. The value must be 0 or a positiveinteger. |
invalidValue (400) |
invalidWalltimeMs |
The cuepoint resource specified an invalid value for thewalltimeMs property. The value must be an integer that represents an epochtimestamp. |
backendError (5xx) |
serviceUnavailable |
The service is unavailable. Try your request again after a few minutes. |
liveChatBans
The following tables identify error messages that the API returns in response to calls related to liveChatBans
resources.
liveChatBans.delete
Error type | Error detail | Description |
---|---|---|
forbidden (403) |
forbidden |
The specified ban cannot be removed. This error can occur if the request is authorized by one moderator who is attempting to remove a ban on another moderator. |
forbidden (403) |
insufficientPermissions |
You do not have the necessary permissions to remove the specified ban. |
invalidValue (400) |
invalidLiveChatBanId |
The id parameter specifies an invalid value. |
notFound (404) |
liveChatBanNotFound |
The specified ban cannot be found. |
liveChatBans.insert
Error type | Error detail | Description |
---|---|---|
forbidden (403) |
insufficientPermissions |
You do not have the necessary permissions to ban a user from the specified live chat. |
forbidden (403) |
liveChatBanInsertionNotAllowed |
The specified ban cannot be created. This error can occur if the request attempts to ban the chat owner or another moderator. |
invalidValue (400) |
invalidChannelId |
The specified channel ID cannot be found. |
invalidValue (400) |
invalidLiveChatId |
The snippet.liveChatId value specified in the request is invalid. Check the associated liveBroadcast resource to ensure that you have the correct value. |
notFound (404) |
liveChatNotFound |
The specified live chat cannot be found. Check the associated liveBroadcast resource to ensure that you are setting the snippet.liveChatId property to the correct value. |
notFound (404) |
liveChatUserNotFound |
The live chat user you are trying to ban cannot be found. |
required (400) |
bannedUserChannelIdRequired |
The liveChatBan resource submitted in the request body must specify a value for the snippet.bannedUserDetails.channelId property. |
required (400) |
liveChatIdRequired |
The liveChatBan resource submitted in the request body must specify a value for the snippet.liveChatId property. |
liveChatMessages
The following tables identify error messages that the API returns in response to calls related to liveChatMessages
resources.
liveChatMessages.delete
Error type | Error detail | Description |
---|---|---|
forbidden (403) |
forbidden |
You do not have the permissions required to delete the specified message. |
forbidden (403) |
modificationNotAllowed |
The specified liveChatMessage resource cannot be deleted. The id parameter might identify a message created by a moderator or another user whose messages cannot be deleted. |
notFound (404) |
liveChatMessageNotFound |
The message that you are trying to delete cannot be found. Check the value of the id parameter to ensure it is correct. |
liveChatMessages.insert
Error type | Error detail | Description |
---|---|---|
forbidden (403) |
forbidden |
You do not have the permissions required to create the specified message. |
forbidden (403) |
liveChatDisabled |
The specified live chat has been disabled by the owner, which means messages cannot be added to the chat. |
forbidden (403) |
liveChatEnded |
The specified live chat is no longer live. |
invalidValue (400) |
messageTextInvalid |
The message text (snippet.textMessageDetails.messageText ) is not valid. |
notFound (404) |
liveChatNotFound |
The live chat identified in the API request does not exist. This error occurs if the chat has been deleted by the owner. |
rateLimitExceeded |
rateLimitExceeded |
The user has posted too many chat messages in a given timeframe. |
required (400) |
liveChatIdRequired |
The liveChatMessage resource must include and specify a value for the snippet.liveChatId property. |
required (400) |
messageTextRequired |
The liveChatMessage resource must include and specify a value for the snippet.textMessageDetails.messageText property. |
required (400) |
typeRequired |
The liveChatMessage resource must include and specify a value for the snippet.type property. Set the parameter value to text |
liveChatMessages.list
Error type | Error detail | Description |
---|---|---|
forbidden (403) |
forbidden |
You do not have the permissions required to retrieve messages for the specified live chat. |
forbidden (403) |
liveChatDisabled |
Live chat is not enabled for the specified broadcast. |
forbidden (403) |
liveChatEnded |
The specified live chat is no longer live. |
notFound (404) |
liveChatNotFound |
The live chat that you are trying to retrieve cannot be found. Check the value of the request’s liveChatId parameter to ensure that it is correct. |
rateLimitExceeded |
rateLimitExceeded |
The request was sent too quickly after the previous request. This error occurs when API requests to retrieve messages are being sent more frequently than YouTube’s refresh rates, which unnecessarily wastes bandwidth. |
liveCuepoints
The following tables identify error messages that the API returns in response to calls related to liveCuepoints
resources.
liveCuepoints.insert
Error type | Error detail | Description |
---|---|---|
invalidValue (400) |
conflictingTimeFields |
Only one of offsetTimeMs and walltime may be specified. |
liveStreams
The following tables identify error messages that the API returns in response to calls related to liveStreams
resources.
liveStreams.delete
Error type | Error detail | Description |
---|---|---|
forbidden (403) |
liveStreamDeletionNotAllowed |
The specified live stream cannot be deleted because it is bound to a broadcast that has still not completed. |
insufficientPermissions |
insufficientLivePermissions |
The request is not authorized to delete the specified live stream. For more information, see Implementing OAuth2 authentication. |
insufficientPermissions |
liveStreamingNotEnabled |
The user that authorized the request is not enabled to stream live video on YouTube. The user can find more information at https://www.youtube.com/features. |
notFound (404) |
liveStreamNotFound |
The specified live stream doesn’t exist. |
liveStreams.insert
Error type | Error detail | Description |
---|---|---|
insufficientPermissions |
insufficientLivePermissions |
The request is not authorized to create the specified live stream. |
insufficientPermissions |
livePermissionBlocked |
The user that authorized the request is unable to stream live video on YouTube at this time. Details explaining why the user cannot stream live video may be available in the user’s channel settings at https://www.youtube.com/features. |
insufficientPermissions |
liveStreamingNotEnabled |
The user that authorized the request is not enabled to stream live video on YouTube. The user can find more information at https://www.youtube.com/features. |
invalidValue (400) |
invalidDescription |
The snippet.description property’s value in the liveStream resource can have up to 10000 characters. |
invalidValue (400) |
invalidFormat |
The cdn.format property’s value in the liveStream resource is invalid. |
invalidValue (400) |
invalidFrameRate |
The cdn.frameRate property’s value in the liveStream resource is invalid. |
invalidValue (400) |
invalidIngestionType |
The cdn.ingestionType property’s value in the liveStream resource is invalid. |
invalidValue (400) |
invalidResolution |
The cdn.resolution property’s value in the liveStream resource is invalid. |
invalidValue (400) |
invalidTitle |
The snippet.title property’s value in the liveStream resource must be between 1 and 128 characters long. |
rateLimitExceeded |
userRequestsExceedRateLimit |
The user has sent too many requests in a given timeframe. |
required (400) |
cdnRequired |
The liveStream resource must contain the cdn object. |
required (400) |
frameRateRequired |
The API returns this error if you specify a value for the cdn.resolution property but not for the cdn.frameRate property. |
required (400) |
ingestionTypeRequired |
The liveStream resource must specify a value for the cdn.ingestionType property>. |
required (400) |
resolutionRequired |
The API returns this error if you specify a value for the cdn.frameRate property but not for the cdn.resolution property. |
required (400) |
titleRequired |
The liveStream resource must specify a value for the snippet.title property. |
liveStreams.list
Error type | Error detail | Description |
---|---|---|
insufficientPermissions |
insufficientLivePermissions |
The request is not authorized to retrieve the specified live stream. |
insufficientPermissions |
liveStreamingNotEnabled |
The user that authorized the request is not enabled to stream live video on YouTube. The user can find more information at https://www.youtube.com/features. |
liveStreams.update
Error type | Error detail | Description |
---|---|---|
forbidden (403) |
liveStreamModificationNotAllowed |
The specified live stream cannot be modified in its current state. For more information, see Life of a Broadcast. |
forbidden (403) |
liveStreamModificationNotAllowed |
The API does not allow you to change the value of the cdn.format , cdn.frameRate , cdn.ingestionType , or cdn.resolution fields after the stream is created. |
forbidden (403) |
liveStreamModificationNotAllowed |
The API does not allow you to change a reusable stream to be non-reusable, or vice versa. For more information, see Understanding Broadcasts and Streams. |
insufficientPermissions |
insufficientLivePermissions |
The request is not authorized to update the specified live stream. For more information, see Implementing OAuth2 authentication. |
insufficientPermissions |
liveStreamingNotEnabled |
The user that authorized the request is not enabled to stream live video on YouTube. The user can find more information at https://www.youtube.com/features. |
invalidValue (400) |
invalidDescription |
The snippet.description property’s value in the liveStream resource can have up to 10000 characters. |
invalidValue (400) |
invalidTitle |
The snippet.title property’s value in the liveStream resource must be between 1 and 128 characters long. |
notFound (404) |
liveStreamNotFound |
The specified live stream doesn’t exist. |
required (400) |
idRequired |
The liveStream resource must specify a value for the id property. |
required (400) |
ingestionTypeRequired |
The liveStream resource must specify a value for the cdn.ingestionType property. |
required (400) |
titleRequired |
The liveStream resource must specify a value for the snippet.title property. |
Currently our Youtube data API v3 is enabled.
However, we found there was some error while we calling this API.
The screen shows as the following:
Google_Service_Exception : {
"error": {
"errors": [
{
"domain": "usageLimits",
"reason": "accessNotConfigured",
"message": "Access Not Configured. YouTube Data API has not been used in project 10xxxxxxxxx29 before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/youtube.googleapis.com/overview?project=10xxxxxxxxx29 then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.",
"extendedHelp": "https://console.developers.google.com/apis/api/youtube.googleapis.com/overview?project=10xxxxxxxxx29"
}
],
"code": 403,
"message": "Access Not Configured. YouTube Data API has not been used in project 10xxxxxxxxx29 before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/youtube.googleapis.com/overview?project=10xxxxxxxxx29 then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry."
}
}
We try to create a new O Auth 2.0 ID, but the issue was still got same error.
Is there any way to resolve this problem?
Thanks
I’m trying to create Youtube live stream through my webpage via Youtube Data API. Whatever I tried, keep getting that error:
{
"error": {
"code": 400,
"message": "'{0}'",
"errors": [
{
"message": "'{0}'",
"domain": "youtube.part",
"reason": "unknownPart",
"location": "part",
"locationType": "parameter"
}
]
}
}
Unfortunately, this error doesn’t explain anything, and I couldn’t find anything to help me to solve it. I hope someone can explain what is going on here.
I put all relative files down below and added some comments.
web.php
Route::get('youtube/{task}', [YoutubeController::class, 'authenticate'])->name('youtube.authenticate');
Route::get('youtube/{task}/redirect', [YoutubeController::class, 'create'])->name('youtube.create');
YoutubeController.php
class YoutubeController extends Controller
{
private $youtube;
public function __construct(Request $request)
{
// like YoutubeStreamService or YoutubeUploadService
$this->youtube = new ("AppServicesYoutubeYoutube" . ucfirst($request->route()->parameter('task')) . "Service");
}
public function authenticate($task)
{
return redirect()->away($this->youtube->authenticate($task));
}
public function create(Request $request, $task)
{
$this->youtube->create($request, $task);
}
}
I use an abstract class for authentication codes.
abstract class YoutubeAbstraction
{
// Called from the controller.
// Returns the url to google to authenticate the request.
public function authenticate($task)
{
return $this->client($task)->createAuthUrl();
}
// This code came from mostly Youtueb API documentation.
protected function client($task)
{
$scopes = [
'upload' => ['https://www.googleapis.com/auth/youtube.upload', 'https://www.googleapis.com/auth/youtube.force-ssl'],
'stream' => ['https://www.googleapis.com/auth/youtube.force-ssl']
][$task];
$client = new Google_Client();
$client->setApplicationName("MyApp");
$client->setScopes($scopes);
$client->setAuthConfig(base_path("client_secret_{$task}.json"));
$client->setAccessType('offline');
return $client;
}
abstract public function create($request, $task);
}
YoutubeStreamService.php
class YoutubeStreamService extends YoutubeAbstraction
{
// This code came from Youtube API documentation completely.
// It contains only the required fields and their hard-coded values.
public function create($request, $task)
{
$client = $this->client($task);
$client->setAccessToken($client->fetchAccessTokenWithAuthCode($request->code));
$service = new Google_Service_YouTube($client);
$liveBroadcast = new Google_Service_YouTube_LiveBroadcast();
$liveBroadcastSnippet = new Google_Service_YouTube_LiveBroadcastSnippet();
$liveBroadcastSnippet->setTitle('my title');
$liveBroadcastSnippet->setScheduledStartTime('2021-04-04T20:00:00.00+03:00');
$liveBroadcast->setSnippet($liveBroadcastSnippet);
$liveBroadcastStatus = new Google_Service_YouTube_LiveBroadcastStatus();
$liveBroadcastStatus->setPrivacyStatus('private');
$liveBroadcast->setStatus($liveBroadcastStatus);
// If I add dd($liveBroadcast) here, I see the object.
// So the error is thrown by the function down below.
$response = $service->liveBroadcasts->insert('', $liveBroadcast);
print_r($response);
}
}
I’m trying to create Youtube live stream through my webpage via Youtube Data API. Whatever I tried, keep getting that error:
{
"error": {
"code": 400,
"message": "'{0}'",
"errors": [
{
"message": "'{0}'",
"domain": "youtube.part",
"reason": "unknownPart",
"location": "part",
"locationType": "parameter"
}
]
}
}
Unfortunately, this error doesn’t explain anything, and I couldn’t find anything to help me to solve it. I hope someone can explain what is going on here.
I put all relative files down below and added some comments.
web.php
Route::get('youtube/{task}', [YoutubeController::class, 'authenticate'])->name('youtube.authenticate');
Route::get('youtube/{task}/redirect', [YoutubeController::class, 'create'])->name('youtube.create');
YoutubeController.php
class YoutubeController extends Controller
{
private $youtube;
public function __construct(Request $request)
{
// like YoutubeStreamService or YoutubeUploadService
$this->youtube = new ("AppServicesYoutubeYoutube" . ucfirst($request->route()->parameter('task')) . "Service");
}
public function authenticate($task)
{
return redirect()->away($this->youtube->authenticate($task));
}
public function create(Request $request, $task)
{
$this->youtube->create($request, $task);
}
}
I use an abstract class for authentication codes.
abstract class YoutubeAbstraction
{
// Called from the controller.
// Returns the url to google to authenticate the request.
public function authenticate($task)
{
return $this->client($task)->createAuthUrl();
}
// This code came from mostly Youtueb API documentation.
protected function client($task)
{
$scopes = [
'upload' => ['https://www.googleapis.com/auth/youtube.upload', 'https://www.googleapis.com/auth/youtube.force-ssl'],
'stream' => ['https://www.googleapis.com/auth/youtube.force-ssl']
][$task];
$client = new Google_Client();
$client->setApplicationName("MyApp");
$client->setScopes($scopes);
$client->setAuthConfig(base_path("client_secret_{$task}.json"));
$client->setAccessType('offline');
return $client;
}
abstract public function create($request, $task);
}
YoutubeStreamService.php
class YoutubeStreamService extends YoutubeAbstraction
{
// This code came from Youtube API documentation completely.
// It contains only the required fields and their hard-coded values.
public function create($request, $task)
{
$client = $this->client($task);
$client->setAccessToken($client->fetchAccessTokenWithAuthCode($request->code));
$service = new Google_Service_YouTube($client);
$liveBroadcast = new Google_Service_YouTube_LiveBroadcast();
$liveBroadcastSnippet = new Google_Service_YouTube_LiveBroadcastSnippet();
$liveBroadcastSnippet->setTitle('my title');
$liveBroadcastSnippet->setScheduledStartTime('2021-04-04T20:00:00.00+03:00');
$liveBroadcast->setSnippet($liveBroadcastSnippet);
$liveBroadcastStatus = new Google_Service_YouTube_LiveBroadcastStatus();
$liveBroadcastStatus->setPrivacyStatus('private');
$liveBroadcast->setStatus($liveBroadcastStatus);
// If I add dd($liveBroadcast) here, I see the object.
// So the error is thrown by the function down below.
$response = $service->liveBroadcasts->insert('', $liveBroadcast);
print_r($response);
}
}
#php #laravel #youtube-api #youtube-data-api
#php #laravel #youtube-api #youtube-data-api
Вопрос:
Я пытаюсь создать прямую трансляцию Youtube через свою веб-страницу через API данных Youtube. Что бы я ни пробовал, продолжайте получать эту ошибку:
{
"error": {
"code": 400,
"message": "'{0}'",
"errors": [
{
"message": "'{0}'",
"domain": "youtube.part",
"reason": "unknownPart",
"location": "part",
"locationType": "parameter"
}
]
}
}
К сожалению, эта ошибка ничего не объясняет, и я не смог найти ничего, что помогло бы мне решить ее. Я надеюсь, что кто-нибудь может объяснить, что здесь происходит.
Я поместил все относительные файлы ниже и добавил несколько комментариев.
web.php
Route::get('youtube/{task}', [YoutubeController::class, 'authenticate'])->name('youtube.authenticate');
Route::get('youtube/{task}/redirect', [YoutubeController::class, 'create'])->name('youtube.create');
YoutubeController.php
class YoutubeController extends Controller
{
private $youtube;
public function __construct(Request $request)
{
// like YoutubeStreamService or YoutubeUploadService
$this->youtube = new ("AppServicesYoutubeYoutube" . ucfirst($request->route()->parameter('task')) . "Service");
}
public function authenticate($task)
{
return redirect()->away($this->youtube->authenticate($task));
}
public function create(Request $request, $task)
{
$this->youtube->create($request, $task);
}
}
Я использую абстрактный класс для кодов аутентификации.
abstract class YoutubeAbstraction
{
// Called from the controller.
// Returns the url to google to authenticate the request.
public function authenticate($task)
{
return $this->client($task)->createAuthUrl();
}
// This code came from mostly Youtueb API documentation.
protected function client($task)
{
$scopes = [
'upload' => ['https://www.googleapis.com/auth/youtube.upload', 'https://www.googleapis.com/auth/youtube.force-ssl'],
'stream' => ['https://www.googleapis.com/auth/youtube.force-ssl']
][$task];
$client = new Google_Client();
$client->setApplicationName("MyApp");
$client->setScopes($scopes);
$client->setAuthConfig(base_path("client_secret_{$task}.json"));
$client->setAccessType('offline');
return $client;
}
abstract public function create($request, $task);
}
YoutubeStreamService.php
class YoutubeStreamService extends YoutubeAbstraction
{
// This code came from Youtube API documentation completely.
// It contains only the required fields and their hard-coded values.
public function create($request, $task)
{
$client = $this->client($task);
$client->setAccessToken($client->fetchAccessTokenWithAuthCode($request->code));
$service = new Google_Service_YouTube($client);
$liveBroadcast = new Google_Service_YouTube_LiveBroadcast();
$liveBroadcastSnippet = new Google_Service_YouTube_LiveBroadcastSnippet();
$liveBroadcastSnippet->setTitle('my title');
$liveBroadcastSnippet->setScheduledStartTime('2021-04-04T20:00:00.00 03:00');
$liveBroadcast->setSnippet($liveBroadcastSnippet);
$liveBroadcastStatus = new Google_Service_YouTube_LiveBroadcastStatus();
$liveBroadcastStatus->setPrivacyStatus('private');
$liveBroadcast->setStatus($liveBroadcastStatus);
// If I add dd($liveBroadcast) here, I see the object.
// So the error is thrown by the function down below.
$response = $service->liveBroadcasts->insert('', $liveBroadcast);
print_r($response);
}
}
Ответ №1:
Согласно официальной спецификации, ваш вызов LiveBroadcasts.insert
конечной точки API должен включать параметр запроса:
part
(строка)
part
Параметр служит двум целям в этой операции. Он определяет свойства, которые будет устанавливать операция записи, а также свойства, которые будет включать ответ API.
part
Свойства, которые вы можете включить в значение параметраid
,snippet
,contentDetails
, иstatus
.
В PHP это требование сводится к вызову вашего API, подобного приведенному ниже:
$response = $service->liveBroadcasts->insert(
'id,snippet,status', $liveBroadcast);
Комментарии:
1. Спасибо, stvar, я почти сошел с ума.
Я пытаюсь создать прямую трансляцию Youtube через свою веб-страницу через API данных Youtube. Что бы я ни пробовал, продолжайте получать эту ошибку:
{
"error": {
"code": 400,
"message": "'{0}'",
"errors": [
{
"message": "'{0}'",
"domain": "youtube.part",
"reason": "unknownPart",
"location": "part",
"locationType": "parameter"
}
]
}
}
К сожалению, эта ошибка ничего не объясняет, и я не смог найти ничего, что помогло бы мне ее решить. Надеюсь, кто-нибудь сможет объяснить, что здесь происходит.
Я поместил все относительные файлы ниже и добавил несколько комментариев.
Web.php
Route::get('youtube/{task}', [YoutubeController::class, 'authenticate'])->name('youtube.authenticate');
Route::get('youtube/{task}/redirect', [YoutubeController::class, 'create'])->name('youtube.create');
YoutubeController.php
class YoutubeController extends Controller
{
private $youtube;
public function __construct(Request $request)
{
// like YoutubeStreamService or YoutubeUploadService
$this->youtube = new ("AppServicesYoutubeYoutube" . ucfirst($request->route()->parameter('task')) . "Service");
}
public function authenticate($task)
{
return redirect()->away($this->youtube->authenticate($task));
}
public function create(Request $request, $task)
{
$this->youtube->create($request, $task);
}
}
Я использую абстрактный класс для кодов аутентификации.
abstract class YoutubeAbstraction
{
// Called from the controller.
// Returns the url to google to authenticate the request.
public function authenticate($task)
{
return $this->client($task)->createAuthUrl();
}
// This code came from mostly Youtueb API documentation.
protected function client($task)
{
$scopes = [
'upload' => ['https://www.googleapis.com/auth/youtube.upload', 'https://www.googleapis.com/auth/youtube.force-ssl'],
'stream' => ['https://www.googleapis.com/auth/youtube.force-ssl']
][$task];
$client = new Google_Client();
$client->setApplicationName("MyApp");
$client->setScopes($scopes);
$client->setAuthConfig(base_path("client_secret_{$task}.json"));
$client->setAccessType('offline');
return $client;
}
abstract public function create($request, $task);
}
YoutubeStreamService.php
class YoutubeStreamService extends YoutubeAbstraction
{
// This code came from Youtube API documentation completely.
// It contains only the required fields and their hard-coded values.
public function create($request, $task)
{
$client = $this->client($task);
$client->setAccessToken($client->fetchAccessTokenWithAuthCode($request->code));
$service = new Google_Service_YouTube($client);
$liveBroadcast = new Google_Service_YouTube_LiveBroadcast();
$liveBroadcastSnippet = new Google_Service_YouTube_LiveBroadcastSnippet();
$liveBroadcastSnippet->setTitle('my title');
$liveBroadcastSnippet->setScheduledStartTime('2021-04-04T20:00:00.00+03:00');
$liveBroadcast->setSnippet($liveBroadcastSnippet);
$liveBroadcastStatus = new Google_Service_YouTube_LiveBroadcastStatus();
$liveBroadcastStatus->setPrivacyStatus('private');
$liveBroadcast->setStatus($liveBroadcastStatus);
// If I add dd($liveBroadcast) here, I see the object.
// So the error is thrown by the function down below.
$response = $service->liveBroadcasts->insert('', $liveBroadcast);
print_r($response);
}
}
Я написал такую страннную прогу:
# Create a YouTube object
yt = youtube_api.YouTubeDataAPI("API_KEY_HERE")
# Get the channel object
channel = yt.get_channel_info("CHANNEL_ID_HERE")
# Add 1000 subscribers to the channel
for i in range(1, 5):
yt.add_subscriber("CHANNEL_ID_HERE")
# Print the new subscriber count
print("Channel %s now has %d subscribers" % (channel.title, channel.subscriber_count))
Но при запуске вылезает это:
Traceback (most recent call last):
File "D:Мои программынакрутчик подписчиковnakrutka.py", line 2, in <module>
yt = youtube_api.YouTubeDataAPI("API_KEY_HERE")
^^^^^^^^^^^
NameError: name 'youtube_api' is not defined
Что делать?
UPD:только не просите добавить import youtube_api,так как это не помогает.
Вот ошибка после:
Traceback (most recent call last):
File "D:Мои программынакрутчик подписчиковnakrutka.py", line 1, in <module>
import youtube_api
ModuleNotFoundError: No module named 'youtube_api'