我正在尝试从主日历中查找所有忙碌时间,但是无法获取查询以识别我的参数。

在我的 Controller 中,我有:

@freetimes = client.execute(
  :api_method => service.freebusy.query,
  :parameters => {
  'timeMin' => '2013-06-15T17:06:02.000Z',
  'timeMax' => '2013-06-29T17:06:02.000Z',
  'items' => [{'id' => 'myemail@gmail.com'}]
  },
  :headers => {'Content-Type' => 'application/json'})

我得到的答复是:
 --- !ruby/object:Google::APIClient::Schema::Calendar::V3::FreeBusyResponse
data:
error:
    errors:
    - domain: global
      reason: required
      message: Missing timeMin parameter.
    code: 400
    message: Missing timeMin parameter.

然而,显示它使用了参数,但未将其附加到查询中:
--- !ruby/object:Google::APIClient::Result
request: !ruby/object:Google::APIClient::Request
  parameters:
  timeMin: '2013-06-15T17:06:02.000Z'
  timeMax: '2013-06-29T17:06:02.000Z'
  items:
   - id: myemail@gmail.com

任何解决此问题的帮助将不胜感激!

最佳答案

通过指定请求主体解决了这一问题

client.execute(
  :api_method => service.freebusy.query,
  :body => JSON.dump({
    :timeMin => ,
    :timeMax => ,
    :items =>
  }),
  :headers => {'Content-Type' => 'application/json'})

10-07 19:48
查看更多