Search code examples
asp.netuploadyoutube-apikeywordhttp-status-code-400

YouTube ASP.NET API: Upload Request Returns 400, Keywords Text "Too Long"


Attempting to upload a video, and this is the response I get back (after several minutes, no less):

<?xml version='1.0' encoding='UTF-8'?>
  <errors>
    <error>
      <domain>yt:validation</domain>
      <code>too_long</code>
      <location type='xpath'>media:group/media:keywords/text()</location>
    </error>
  </errors>

The plain text I'm sending in as the keywords:

DEMOGXS53, Catchers, 34.00, Fully Closed, Mizuno, $0 - $99.99, Demo Gloves, Female Fastpitch

The value of Keywords on the YouTube.Video object I'm passing into the Upload method:

DEMOGXS53%2c+Catchers%2c+34.00%2c+Fully+Closed%2c+Mizuno%2c+%240+-+%2499.99%2c+Demo+Gloves%2c+Female+Fastpitch

Nothing about what I'm sending in appears to be breaking YouTube's rules. (individual keywords max character length of 30, total keywords max character length of 500. See here: https://developers.google.com/youtube/2.0/reference#youtube_data_api_tag_media%3akeywords) Any ideas?


Solution

  • Solved, credit to Aristos for pointing it out. I was URL-encoding the entire string of keywords, so YouTube could not parse out the commas and treated it all as one big keyword.

    If you need to URL-encode some characters (like an apostrophe - which is an illegal character that will result in yet another 400 response if left in), you'll need to manually find and replace them in your code.