我正在尝试使用Ruby Gmail API在我的Gmail帐户中创建一个新标签。
我有一个工作连接,可以访问我的消息、列表标签等。
然而,当我尝试使用
create_user_label
我得到以下错误。
Google::Apis::ClientError: invalidArgument: Invalid request
/Users/brianrhea/.rvm/gems/ruby-2.4.2/gems/google-api-client-0.19.1/lib/google/apis/core/http_command.rb:218:in 'check_status'
/Users/brianrhea/.rvm/gems/ruby-2.4.2/gems/google-api-client-0.19.1/lib/google/apis/core/api_command.rb:116:in 'check_status'
/Users/brianrhea/.rvm/gems/ruby-2.4.2/gems/google-api-client-0.19.1/lib/google/apis/core/http_command.rb:183:in 'process_response'
/Users/brianrhea/.rvm/gems/ruby-2.4.2/gems/google-api-client-0.19.1/lib/google/apis/core/http_command.rb:299:in 'execute_once'
/Users/brianrhea/.rvm/gems/ruby-2.4.2/gems/google-api-client-0.19.1/lib/google/apis/core/http_command.rb:104:in 'block (2 levels) in execute'
/Users/brianrhea/.rvm/gems/ruby-2.4.2/gems/retriable-3.1.1/lib/retriable.rb:61:in 'block in retriable'
/Users/brianrhea/.rvm/gems/ruby-2.4.2/gems/retriable-3.1.1/lib/retriable.rb:57:in 'times'
/Users/brianrhea/.rvm/gems/ruby-2.4.2/gems/retriable-3.1.1/lib/retriable.rb:57:in 'retriable'
/Users/brianrhea/.rvm/gems/ruby-2.4.2/gems/google-api-client-0.19.1/lib/google/apis/core/http_command.rb:101:in 'block in execute'
/Users/brianrhea/.rvm/gems/ruby-2.4.2/gems/retriable-3.1.1/lib/retriable.rb:61:in 'block in retriable'
/Users/brianrhea/.rvm/gems/ruby-2.4.2/gems/retriable-3.1.1/lib/retriable.rb:57:in 'times'
/Users/brianrhea/.rvm/gems/ruby-2.4.2/gems/retriable-3.1.1/lib/retriable.rb:57:in 'retriable'
/Users/brianrhea/.rvm/gems/ruby-2.4.2/gems/google-api-client-0.19.1/lib/google/apis/core/http_command.rb:93:in 'execute'
/Users/brianrhea/.rvm/gems/ruby-2.4.2/gems/google-api-client-0.19.1/lib/google/apis/core/base_service.rb:360:in 'execute_or_queue_command'
/Users/brianrhea/.rvm/gems/ruby-2.4.2/gems/google-api-client-0.19.1/generated/google/apis/gmail_v1/service.rb:543:in 'create_user_label'
/Users/brianrhea/Sites/myproject/lib/tasks/gmail_api.rake:47:in 'block in <top (required)>'
/Users/brianrhea/.rvm/gems/ruby-2.4.2/gems/rake-12.3.0/exe/rake:27:in '<top (required)>'
/Users/brianrhea/.rvm/gems/ruby-2.4.2/bin/ruby_executable_hooks:15:in 'eval'
/Users/brianrhea/.rvm/gems/ruby-2.4.2/bin/ruby_executable_hooks:15:in '<main>'
我在堆栈跟踪中的失败代码是:
client = Google::Apis::GmailV1::GmailService.new
client.authorization = current_user.Token.fresh_token
user_id = 'me'
label = {
"label_list_visibility" => "labelShow",
"message_list_visibility" => "show",
"name" => "TestLabel"
}
client.create_user_label(user_id, label)
API的代码
create_user_label
要求
label_object
我以为这是我创造的。
任何帮助都将不胜感激。