我试图从我的主日历中找到所有忙碌的时间,但我无法通过查询来识别我的参数。
在我的控制器中我有:
@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
任何帮助解决这个问题都将非常感谢!
答案 0 :(得分:6)
通过指定请求正文
解决了这个问题client.execute(
:api_method => service.freebusy.query,
:body => JSON.dump({
:timeMin => ,
:timeMax => ,
:items =>
}),
:headers => {'Content-Type' => 'application/json'})
答案 1 :(得分:2)
我遇到了类似的问题。另一种方法是,您可以构建一个FreeBusyRequest对象 像这样:
body = Google::Apis::CalendarV3::FreeBusyRequest.new
body.items = [calendar_id]
body.time_min = "2016-06-29T13:00:00z"
body.time_max = "2016-06-29T21:00:00z"
body
``` 然后你可以将它传递给CalendarService对象,如下所示:
service = Google::Apis::CalendarV3::CalendarService.new
service.authorization = client
service.query_freebusy(body)
这肯定会返回一个身体的状态200响应。