大佬教程收集整理的这篇文章主要介绍了Fusion Tables:在尝试通过Ruby的RestClient gem更新表格样式时,为什么我一直收到“400 Bad Request”错误,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
这是我的代码:
require 'rest_client' tablEID = '<StriNG CONTAINING TABLEID>' stylEID = '<StriNG CONTAINING STYLEID>' key = '<StriNG CONTAINING MY FUSION TABLES API KEY>' table_url = "https://www.googleapis.com/fusiontables/v1/tables/#{tablEID}/styles/#{stylEID}?key=#{key}" update = '{"polygonOptions": {"strokeColor":"#ffffff"}}' token = 'StriNG CONTAINING AUTHORIZATION TOKEN' RestClient.put table_url,update,{"Authorization" => "Bearer #{token}"}
当我运行该代码时,我收到此错误:
C:/Ruby193/lib/ruby/gems/1.9.1/gems/rest-client-1.6.7/lib/restclient/abstract_response.rb:48:in `return!': 400 Bad request (RestClient::Badrequest) from C:/Ruby193/lib/ruby/gems/1.9.1/gems/rest-client-1.6.7/lib/restclient/request.rb:230:in `process_result' from C:/Ruby193/lib/ruby/gems/1.9.1/gems/rest-client-1.6.7/lib/restclient/request.rb:178:in `block in transmit' from C:/Ruby193/lib/ruby/1.9.1/net/http.rb:745:in `start' from C:/Ruby193/lib/ruby/gems/1.9.1/gems/rest-client-1.6.7/lib/restclient/request.rb:172:in `transmit' from C:/Ruby193/lib/ruby/gems/1.9.1/gems/rest-client-1.6.7/lib/restclient/request.rb:64:in `execute' from C:/Ruby193/lib/ruby/gems/1.9.1/gems/rest-client-1.6.7/lib/restclient/request.rb:33:in `execute' from C:/Ruby193/lib/ruby/gems/1.9.1/gems/rest-client-1.6.7/lib/restclient.rb:80:in `put'
当我将更新代码输入到Google’s official Style request PUT maker thingie时,更新有效.但是当我运行我的Ruby代码时它不起作用.
有谁知道我做错了什么?
编辑:我在RestClient.log = logger中添加的额外输出
RestClient.put "https://www.googleapis.com/fusiontables/v1/tables/<MY TABLE ID HERE>/styles/4?key=<AND HERE'S WHERE MY FUSION TABLE API KEY GOES>","{\"polygonOptions\":{\"strokeColor\":\"#ffffff\"}}","Accept"=>"*/*; q=0.5,application/xml","Accept-Encoding"=>"gzip,deflate","Authorization"=>"Bearer <THIS CONTAINS THE BEARER StriNG>","Content-Length"=>"44" # => 400 Badrequest | application/json 255 bytes
话虽如此,你可以enable debugging for your RestClient并发布RestClient调用的输出以及谷歌官方PUT制造商的输出(我喜欢你的技术术语)吗?比较两者应该显示它们之间的差异以及Google与您的不同之处.
以上是大佬教程为你收集整理的Fusion Tables:在尝试通过Ruby的RestClient gem更新表格样式时,为什么我一直收到“400 Bad Request”错误全部内容,希望文章能够帮你解决Fusion Tables:在尝试通过Ruby的RestClient gem更新表格样式时,为什么我一直收到“400 Bad Request”错误所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。