Note: The YouTube Data API (v2) has been officially deprecated as of March 4, 2014. Please refer to our deprecation policy for more information.
This section discusses the XML response that may accompany a failed API request. Please see the reference guide for more information about the HTTP response codes that the API returns.
When an API request fails, YouTube will return an HTTP 4xx or 5xx response code that generically identifies the failure as well as an XML response that provides more specific information about the error(s) that caused the failure. For each error, the XML response includes a <domain> element, <code> element and possibly a <location> element. The following subsections explain the possible values for these elements and provides a sample error response for each error. Note that error responses may contain more than one error.
This section describes the following types of errors:
A validation error, which is identified by a <domain> tag value of yt:validation, reports a problem related to an XML element value in a request to insert or update an entry. API functions that insert or update videos or other data can report yt:validation errors. Validation errors are typically reported with an HTTP 400 response code.
For all validation errors, the <location> tag defines the error location as an Xpath pointing to the XML tag that caused the request to fail. The Xpath location is specified relative to the <entry> tag in the request.
For validation errors, the <code> tag will contain one of the following values:
required - This code indicates that a required field is missing or has an empty value.
deprecated - This code indicates that an element's value has been deprecated and is no longer valid. For example, a video category name that has been retired may not be associated with newly added or updated videos.
invalid_format - This code indicates that an XML element's value does not match an expected format. For example, you could receive this error if you specify invalid coordinates in the <gml:pos> tag.
invalid_character - This code indicates that an XML field value contains an invalid character. For example, video titles may not contain a less than (<) character.
too_long - This code indicates that an XML element's value exceeds the maximum allowable length. For example, video titles must be 60 characters or less.
A quota error, which is identified by a <domain> tag value of yt:quota, identifies a problem related to irregular API usage.
For quota errors, the <code> tag will contain one of the following values:
too_many_recent_calls - This code indicates that the API servers have received too many calls from the same caller in a short amount of time. This error will not specify a location. The API response will not include a <location> tag for this type of error.
<?xml version='1.0' encoding='UTF-8'?> <errors> <error> <domain>yt:quota</domain> <code>too_many_recent_calls</code> </error> </errors>
If you receive this error, then your application has exceeded our current limits on API calls. We recommend that you wait a few minutes and then try your request again.
too_many_entries - This code indicates that the user is attempting to exceed a storage limit on his account and must delete existing entries before inserting new entries. For this type of error, the <location> tag identifies the feed that caused the error.
Authentication and authorization errors
An authentication error, which is identified by a <domain> tag value of yt:authentication, identifies a problem related to an improperly authorized request to execute an API function that requires user authorization. Authentication errors could be identified with HTTP 401 or 403 response codes.
Authentication errors may include a <location> element. If so, the element's value will identify the header that caused the authentication error.
For authentication errors, the <code> tag will contain one of the following values:
InvalidToken - This code indicates that the token specified in the Authorization header is invalid.
TokenExpired - This code indicates that the token specified in the Authorization header has expired.
A service error, which is identified by a <domain> tag value of yt:service, identifies an authentication error that occurs when the YouTube site is undergoing temporary maintenance. This error may occur if you are trying to execute insert (POST), update (PUT) or delete (DELETE) operations. This error will not occur if you are only executing read (GET) operations.
For service errors, the <code> tag will contain the following value:
disabled_in_maintenance_mode - This code indicates that POST, PUT and DELETE operations cannot be executed because the site is temporarily in maintenance mode. If you receive this error, wait a few minutes and try your request again.
youtube_signup_required - This code is returned in API version
2.1when a user with an unlinked Google Account submits an API request that requires the authenticated user to have a YouTube channel. If you receive this error, your application should indicate that the requested operation requires the user to have a YouTube channel and should display an option to link to https://www.youtube.com/create_channel. That page will let the user associate her Google Account with a YouTube channel. If you are building a mobile application, you can bypass a redirect by presenting a link to https://m.youtube.com/create_channel instead.