I am trying to find all the freebusy times from my primary calendar, but I cannot get the query to recognize my parameters.
In my controller I have:
@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' => '[email protected]'}]
},
:headers => {'Content-Type' => 'application/json'})
the response I get is:
--- !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.
However is shows that it took the parameters, but they did not get attached to the query:
--- !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: [email protected]
Any help solving this would be greatly appreciated!
solved this by specifying the request body
client.execute(
:api_method => service.freebusy.query,
:body => JSON.dump({
:timeMin => ,
:timeMax => ,
:items =>
}),
:headers => {'Content-Type' => 'application/json'})
I was having a similar problem. An alternative, is that you can build a FreeBusyRequest object.
Like this:
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
``` and then you can pass it into a CalendarService object like this:
service = Google::Apis::CalendarV3::CalendarService.new
service.authorization = client
service.query_freebusy(body)
this will definitely return a status 200 response with a body.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With