gpt4 book ai didi

ruby-on-rails - Google Calendar API V3 - 插入日历

转载 作者:太空宇宙 更新时间:2023-11-03 18:20:53 24 4
gpt4 key购买 nike

我在玩 Google 日历 API 时发现了这个:

Google Calendar V3 Insert

Ruby 代码似乎不是 Ruby 代码,所以我将 calendar_list 和 calendar.get 中的信息移植到这里。我不确定为什么参数摘要没有被选为标题。

def create      
@auth = request.env["omniauth.auth"]
@token = @auth["credentials"]["token"]
client = Google::APIClient.new
client.authorization.access_token = @token
service = client.discovered_api('calendar', 'v3')
@result = client.execute(
:api_method => service.calendars.insert,
:parameters => {"summary" => 'Calendar Title'},
:headers => {'Content-Type' => 'application/json'})
end

导致错误

--- !ruby/object:Google::APIClient::Schema::Calendar::V3::Calendar
data:
error:
errors:
- domain: global
reason: required
message: Missing title.
code: 400
message: Missing title.

最佳答案

老实说,我还没有尝试过使用 ruby​​ 的 google api,但是在查看你的错误和 google documentation 时我相信摘要等于标题(如您所述)。

另外,在看其他examples of inserts (也许不是日历)我注意到 API 可以采用 :body 属性,它可能(在您的情况下)包含实际的日历数据(即“摘要”)。和 here它实际上在 tryit 下提到了请求“body”。

再说一次,我还没有尝试过这个,但我会尝试以下操作:

  @result = client.execute(
:api_method => service.calendars.insert,
:parameters => # not sure what parameters the insert needs,
:body => JSON.dump(cal), # where cal is the object containing at least "summary".
:headers => {'Content-Type' => 'application/json'})

关于ruby-on-rails - Google Calendar API V3 - 插入日历,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18552272/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com