google-api-ruby-client icon indicating copy to clipboard operation
google-api-ruby-client copied to clipboard

YouTube set_thumbnail not working

Open mihir-kumar-thakur opened this issue 9 years ago • 5 comments

set_thumbnails asks for videoId

my code :-

youtube = Google::Apis::YoutubeV3::YouTubeService.new
 youtube.authorization = authorize
 
youtube.set_thumbnail("uPT4SVOuhHI", upload_source: 
UploadIO.new("/home/geobeats/Desktop/test.jpg", "image/jpeg").io, content_type: 'application/octet-
stream'

error:- `Sending upload start command to https://www.googleapis.com/upload/youtube/v3/thumbnails/set? Upload status final Error - #<Google::Apis::ClientError: required: Required parameter: videoId>

Google::Apis::ClientError: required: Required parameter: videoId from /home/geobeats/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/google-api-client-0.13.1/lib/google/apis/core/http_command.rb:218:in check_status' from /home/geobeats/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/google-api-client-0.13.1/lib/google/apis/core/api_command.rb:116:in check_status' from /home/geobeats/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/google-api-client-0.13.1/lib/google/apis/core/http_command.rb:183:in process_response' from /home/geobeats/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/google-api-client-0.13.1/lib/google/apis/core/upload.rb:170:in process_response' from /home/geobeats/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/google-api-client-0.13.1/lib/google/apis/core/upload.rb:246:in execute_once' from /home/geobeats/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/google-api-client-0.13.1/lib/google/apis/core/http_command.rb:104:in block (2 levels) in execute' from /home/geobeats/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/retriable-3.1.1/lib/retriable.rb:61:in block in retriable' from /home/geobeats/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/retriable-3.1.1/lib/retriable.rb:57:in times' from /home/geobeats/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/retriable-3.1.1/lib/retriable.rb:57:in retriable' from /home/geobeats/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/google-api-client-0.13.1/lib/google/apis/core/http_command.rb:101:in block in execute' from /home/geobeats/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/retriable-3.1.1/lib/retriable.rb:61:in block in retriable' from /home/geobeats/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/retriable-3.1.1/lib/retriable.rb:57:in times' from /home/geobeats/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/retriable-3.1.1/lib/retriable.rb:57:in retriable' from /home/geobeats/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/google-api-client-0.13.1/lib/google/apis/core/http_command.rb:93:in execute' from /home/geobeats/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/google-api-client-0.13.1/lib/google/apis/core/base_service.rb:360:in execute_or_queue_command' from /home/geobeats/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/google-api-client-0.13.1/generated/google/apis/youtube_v3/service.rb:3839:in set_thumbnail' ` please someone help to resolve this issue

mihir-kumar-thakur avatar Aug 02 '17 07:08 mihir-kumar-thakur

I'm working on this in #672 .

daigo424 avatar May 05 '18 11:05 daigo424

Thanks for working on fixing this. Is this still an issue for you?

TheRoyalTnetennba avatar Jun 06 '18 00:06 TheRoyalTnetennba

@TheRoyalTnetennba Still an issue, can the fix be merged?

meanphil avatar Oct 02 '18 01:10 meanphil

👍

danicuki avatar Sep 13 '19 19:09 danicuki

After some research, we determined the following.

  • The issue is that the internal HttpCommand base class tries to form-encode query parameters (and in doing so removes them from the URL) if the body is unset. Such behavior really should not happen for most Google APIs, and especially not for upload requests: they expect JSON documents or upload data, but not form encoding. And this particular call definitely expects the query parameters to remain in the URL.
  • #841 fixes this by ensuring the upload command classes initialize the body field properly, preventing the HttpCommand base class from hijacking it.
  • Note that #672 appears to solve the issue, but only by accident—because it happens to set the body to something. (The actual value is ignored. It turns out the client correctly omits any SetThumbnailRequest type. No such type is defined by the API, and no such type is expected to be sent as part of the request.)

Once #841 is validated, the next release of google-api-client (expected Nov 11) should include the fix.

dazuma avatar Nov 05 '19 02:11 dazuma