Rails 中的 Google freebusy api 调用无法识别参数 [英] Google freebusy api call in rails will not recognizing parameters

查看:12
本文介绍了Rails 中的 Google freebusy api 调用无法识别参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图从我的主日历中查找所有空闲时间,但我无法让查询识别我的参数.

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' => '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.

然而显示它接受了参数,但它们没有附加到查询中:

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: myemail@gmail.com

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

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'})

这篇关于Rails 中的 Google freebusy api 调用无法识别参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆