YouTube GData API returning error 400 when uploading a video

I’ve been battling with the YouTube API for the last 2 days now and found the single line of code that has been preventing me from generating a form upload token.

I was following the example code at and kept receiving “Expected response code 200, got 400″ when calling the getFormUploadToken function. HTTP error code 400 is a bad request which wasn’t really much help.

Eventually I found the problem and I will own up straight away that it was basically my fault, I’d made what I considered to be a slight change to the example code, I changed

$mediaGroup->category = array(  $yt->newMediaCategory()->setText('Autos')->setScheme




to the following

$mediaGroup->category = $yt->newMediaCategory()->setText('Autos')->setScheme

because I wasn’t interested in multiple categories, just something simple. My mistake was not in removing the two developer tags but removing the array(). This took me almost an entire day to realise and resulted in a “You have to be kidding” comment from me once fixed. *Sigh* oh well, not going to get that time back but at least I learned not to mess with example code.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>