Ruby on rails 使用Ruby Gmail API向Gmail添加标签

Ruby on rails 使用Ruby Gmail API向Gmail添加标签,ruby-on-rails,ruby,api,gmail-api,Ruby On Rails,Ruby,Api,Gmail Api,我正在尝试使用Ruby Gmail API在我的Gmail帐户中创建一个新标签 我有一个工作连接,可以访问我的邮件、列表标签等 然而,当我尝试使用时,我得到以下错误 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:21

我正在尝试使用Ruby Gmail API在我的Gmail帐户中创建一个新标签

我有一个工作连接,可以访问我的邮件、列表标签等

然而,当我尝试使用时,我得到以下错误

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>'
create\u user\u label
中的API代码调用了一个我以为自己正在创建的API

任何帮助都将不胜感激。

如果您需要使用类型为
Google::api::GmailV1::Label
的对象作为您的
Label\u对象

@param[Google::api::GmailV1::Label]Label\u对象

查看将
标签
变量从散列更改为此变量是否有效:

label = Google::Apis::GmailV1::Label.new({
  name: 'TestLabel',
  label_list_visibility: 'labelShow',
  message_list_visibility: 'show',
})
假设您需要使用类型为
Google::api::GmailV1::Label
的对象作为
Label\u对象

@param[Google::api::GmailV1::Label]Label\u对象

查看将
标签
变量从散列更改为此变量是否有效:

label = Google::Apis::GmailV1::Label.new({
  name: 'TestLabel',
  label_list_visibility: 'labelShow',
  message_list_visibility: 'show',
})
五颜六色


用颜色钉住它。谢谢搞定了。谢谢
label = Google::Apis::GmailV1::Label.new({
   name: 'Label Name',
   label_list_visibility: 'labelShow',
   message_list_visibility: 'show',
   color: { background_color: "#fb4c2f", text_color: "#000000" 
  }
 })