尝试使用 Gmail 的 Ruby API 修改标签时出现“未指定标签添加或删除错误”
“Error no label add or removes specified” when trying to modify labels using Gmail's Ruby API
我查看了 https://www.rubydoc.info/github/google/google-api-ruby-client/Google/Apis/GmailV1/ModifyThreadRequest and the examples https://developers.google.com/gmail/api/v1/reference/users/labels/update 的 Python 和 JS,但无法弄清楚如何在 ruby 中正确格式化请求。
我正在尝试:
service.modify_thread('me',thread_id,{'add_label_ids'=>['UNREAD']})
和对象的各种其他排列,但除了 Google::Apis::ClientError: invalidArgument: No label add or removes specified
之外无法得到任何响应。
感谢任何帮助
modify_thread
根据 documentation.
期望 Google::Apis::GmailV1::ModifyThreadRequest
对象作为第三个参数
在 ModifyThreadRequest 构造函数的 source 中,您可以看到它在其参数中查找键 :add_label_ids
。
因此,如果 modify_thread
创建 ModifyThreadRequest 对象本身,那么
service.modify_thread('me',thread_id, add_label_ids: ['UNREAD'])
应该可以。
如果失败我会尝试
mtr = Google::Apis::GmailV1::ModifyThreadRequest.new(add_label_ids: ['UNREAD'])
service.modify_thread('me', thread_id, mtr)
我查看了 https://www.rubydoc.info/github/google/google-api-ruby-client/Google/Apis/GmailV1/ModifyThreadRequest and the examples https://developers.google.com/gmail/api/v1/reference/users/labels/update 的 Python 和 JS,但无法弄清楚如何在 ruby 中正确格式化请求。
我正在尝试:
service.modify_thread('me',thread_id,{'add_label_ids'=>['UNREAD']})
和对象的各种其他排列,但除了 Google::Apis::ClientError: invalidArgument: No label add or removes specified
之外无法得到任何响应。
感谢任何帮助
modify_thread
根据 documentation.
Google::Apis::GmailV1::ModifyThreadRequest
对象作为第三个参数
在 ModifyThreadRequest 构造函数的 source 中,您可以看到它在其参数中查找键 :add_label_ids
。
因此,如果 modify_thread
创建 ModifyThreadRequest 对象本身,那么
service.modify_thread('me',thread_id, add_label_ids: ['UNREAD'])
应该可以。 如果失败我会尝试
mtr = Google::Apis::GmailV1::ModifyThreadRequest.new(add_label_ids: ['UNREAD'])
service.modify_thread('me', thread_id, mtr)