捕获的错误无效的请求错误-#<google :: apis :: clienterror:invalid =“” request =“”>

时间:2018-09-04 22:12:23

标签: ruby-on-rails ruby google-api-client google-my-business-api

我正在尝试使用这些宝石列出Google My Business API中的评论

gem 'google-api-client', '~> 0.23.7'
gem 'googleauth', '~> 0.5.1'

我正在尝试通过两种方式解决此问题:

require 'google/apis/mybusiness_v3'

MybusinessV3 = Google::Apis::MybusinessV3
mybusiness = MybusinessV3::MybusinessService.new
mybusiness.authorization = Google::Auth::ClientId.new(ENV['GOOGLE_CLIENT_ID'], ENV['GOOGLE_CLIENT_SECRET'])
mybusiness.list_reviews('Ayenda 1011 Chapinero')

require 'googleauth'
require 'googleauth/stores/redis_token_store'
require 'google/apis/mybusiness_v3'

MybusinessV3 = Google::Apis::MybusinessV3
mybusiness = MybusinessV3::MybusinessService.new

client_id = Google::Auth::ClientId.new(ENV['GOOGLE_CLIENT_ID'], ENV['GOOGLE_CLIENT_SECRET'])
token_store = Google::Auth::Stores::RedisTokenStore.new(redis: Redis.new)
scope = "https://www.googleapis.com/auth/plus.business.manage"
authorizer = Google::Auth::WebUserAuthorizer.new(client_id, scope, token_store)
mybusiness.authorization = authorizer
mybusiness.list_reviews('Ayenda 1011 Chapinero')

问题是,在两种情况下,我都遇到以下错误:

Sending HTTP get https://mybusiness.googleapis.com/v3/Ayenda%201011%20Chapinero/reviews?
404
#<HTTP::Message:0x007f81cb790780 @http_header=#<HTTP::Message::Headers:0x007f81cb790758 @http_version="1.1", @body_size=0, @chunked=false, @request_method="GET", @request_uri=#<Addressable::URI:0x3fc0e5c5ddd0 URI:https://mybusiness.googleapis.com/v3/Ayenda%201011%20Chapinero/reviews?>, @request_query=nil, @request_absolute_uri=nil, @status_code=404, @reason_phrase="Not Found", @body_type=nil, @body_charset=nil, @body_date=nil, @body_encoding=#<Encoding:UTF-8>, @is_request=false, @header_item=[["Date", "Tue, 04 Sep 2018 20:26:37 GMT"], ["Content-Type", "text/html; charset=UTF-8"], ["Server", "ESF"], ["Content-Length", "1598"], ["X-XSS-Protection", "1; mode=block"], ["X-Frame-Options", "SAMEORIGIN"], ["X-Content-Type-Options", "nosniff"], ["Alt-Svc", "quic=\":443\"; ma=2592000; v=\"44,43,39,35\""]], @dumped=false>, @peer_cert=#<OpenSSL::X509::Certificate: subject=#<OpenSSL::X509::Name:0x007f81cb771290>, issuer=#<OpenSSL::X509::Name:0x007f81cb771268>, serial=#<OpenSSL::BN:0x007f81cb771240>, not_before=2018-08-14 07:48:19 UTC, not_after=2018-10-23 07:38:00 UTC>, @http_body=#<HTTP::Message::Body:0x007f81cb7906e0 @body="<!DOCTYPE html>\n<html lang=en>\n  <meta charset=utf-8>\n  <meta name=viewport content=\"initial-scale=1, minimum-scale=1, width=device-width\">\n  <title>Error 404 (Not Found)!!1</title>\n  <style>\n    *{margin:0;padding:0}html,code{font:15px/22px arial,sans-serif}html{background:#fff;color:#222;padding:15px}body{margin:7% auto 0;max-width:390px;min-height:180px;padding:30px 0 15px}* > body{background:url(//www.google.com/images/errors/robot.png) 100% 5px no-repeat;padding-right:205px}p{margin:11px 0 22px;overflow:hidden}ins{color:#777;text-decoration:none}a img{border:0}@media screen and (max-width:772px){body{background:none;margin-top:0;max-width:none;padding-right:0}}#logo{background:url(//www.google.com/images/branding/googlelogo/1x/googlelogo_color_150x54dp.png) no-repeat;margin-left:-5px}@media only screen and (min-resolution:192dpi){#logo{background:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) no-repeat 0% 0%/100% 100%;-moz-border-image:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) 0}}@media only screen and (-webkit-min-device-pixel-ratio:2){#logo{background:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) no-repeat;-webkit-background-size:100% 100%}}#logo{display:inline-block;height:54px;width:150px}\n  </style>\n  <a href=//www.google.com/><span id=logo aria-label=Google></span></a>\n  <p><b>404.</b> <ins>That’s an error.</ins>\n  <p>The requested URL <code>/v3/Ayenda%201011%20Chapinero/reviews?</code> was not found on this server.  <ins>That’s all we know.</ins>\n", @size=0, @positions=nil, @chunk_size=nil>, @previous=nil>
Caught error Invalid request
Error - #<Google::Apis::ClientError: Invalid request>

Google::Apis::ClientError: Invalid request
from /Users/andru1989/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/google-api-client-0.23.7/lib/google/apis/core/http_command.rb:218:in `check_status'

我真的不知道该怎么办,因为据我所知,关于Google::Apis::MybusinessV3的文档不足

预先感谢

0 个答案:

没有答案