ip2k / google-api-ruby-client

Automatically exported from code.google.com/p/google-api-ruby-client
Apache License 2.0
0 stars 0 forks source link

Unable to upload video to Youtube #80

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. setup client to use youtubeV3 API
  client = Google::APIClient.new(:application_name => 'my_app')
  client.discovered_api('youtube','v3')

2. setup client authorization and fetch access token 
client.authorization.client_id = '<CLIENT_ID>'
.....
client.authorization.code = '<CODE>'
client.authorization.fetch_access_token!

3. send the following request 
media = Google::APIClient::UploadIO.new('test.mov', 'video/mp4')
result = client.execute(
  :api_method => youtube.videos.insert,
  :parameters => {
    :part => 'snippet,status',
    :body => {
      :snippet => { :title => 'Test vid',
                            :description => 'testing upload' },
      :status => { :privacyStatus => 'unlisted' }
    },
  :media_body => media
  }
)

What is the expected output? What do you see instead?
Expected: Should upload the file to Youtube
Received: 
{
 "error": {
  "errors": [
   {
    "domain": "youtube.video",
    "reason": "mediaBodyRequired",
    "message": "Bad Request",
    "locationType": "other",
    "location": "body"
   }
  ],
  "code": 400,
  "message": "Bad Request"
 }
}

What version of the product are you using? On what operating system?
google-api-client (0.6.2)
OSX 10.7.5
ruby 1.9.3p286 (2012-10-12 revision 37165) [x86_64-darwin11.4.2]

Please provide any additional information below.
Tried variations on media_body such as mediaBody, mediabody with same result

Original issue reported on code.google.com by george.m...@machinima.com on 9 Feb 2013 at 1:50

GoogleCodeExporter commented 9 years ago
:body & :media_body shouldn't be inside parameters. Should be something along 
the lines of:

media = Google::APIClient::UploadIO.new('test.mov', 'video/mp4')
result = client.execute(
  :api_method => youtube.videos.insert,
  :body_object => {
    :snippet => { :title => 'Test vid',
                          :description => 'testing upload' },
    :status => { :privacyStatus => 'unlisted' }
  },
 :media_body => media,
 :parameters => {
    :part => 'snippet,status',
    :uploadType => 'resumable'
  }
)

Not sure if Youtube supports resumable upload, if not, try 'multipart'

Original comment by sba...@google.com on 15 Feb 2013 at 10:49