1

我提供了“id”,但它总是返回“必需参数:id”的错误

顺便说一句,如果我使用普通请求(即非批处理),那么相同的代码

:api_method => yt.playlist_items.delete,
:parameters => {:id => ids[0]}

将成功没有错误。但是如果我使用批处理请求,那么它总是失败!

这是我的代码

require 'google/api_client'

client = Google::APIClient.new(:application_name => 'YouBoard', :application_version => '1.0')
yt = client.discovered_api('youtube', 'v3')
client.authorization.access_token = 'Some Access Token'

response = client.execute!(
  :api_method => yt.playlist_items.list,
  :parameters => {
    :playlistId => pid,
  :part => 'id'
}
)

# Get playlist_item's id
ids = response.data.items.collect {|x| x.id}

batch = Google::APIClient::BatchRequest.new() do |result|
  p result.data
end

batch.add(
 :api_method => yt.playlist_items.delete,
 :parameters => {:id => ids[0]}
)

client.execute!(batch)

这是错误

"error"=>{"errors"=>[{
"domain"=>"global", 
"reason"=>"required", 
"message"=>"Required parameter: id", 
"locationType"=>"parameter", 
"location"=>"id"}], "code"=>400, "message"=>"Required parameter: id"}}
4

1 回答 1

0

这是由于 Google API Ruby 客户端库中的一个错误造成的。我在图书馆的问题跟踪器中跟进:https ://code.google.com/p/google-api-ruby-client/issues/detail?id=79

于 2013-02-13T18:24:06.330 回答