草庐IT

restclient

全部标签

ruby-on-rails - 将 restclient 与多部分帖子一起使用

我将restclient用于多部分表单,以将数据发送到restfulweb服务(它是Panda视频编码服务)。不过,诀窍在于我传递给restclient(Technoweenie分支)的文件来自用户提交的我自己的表单。那么,让我们来看看这个。用户将文件发布到我的Rails应用程序。在我的Controller中,它从params[:file]接收文件。然后我想使用RestClient将params[:file]传递给Panda。我在Panda服务器上遇到的错误如下。我注意到堆栈跟踪中的文件参数也在一个字符串中(我假设Panda将其转换为字符串以获得更好的堆栈跟踪)。~Startedreq

ruby - 如何让 Ruby 的 RestClient 使用多值查询参数?

使用RestClientgem,我需要创建如下请求:GEThttp://host/path?p=1&p=2完成此操作的正确语法是什么?请注意,接收主机不是Rails。尝试过:resource=RestClient::Resource.new('http://host/path')params={p:'1',p:'2'}#^Overridesparamtohavevalueof2(?p=2)params={p:['1','2']}#^resultsin'p[]=abc&p[]=cde'(array[]indicatorsnotwanted)resource.get({params:par

ruby - 融合表 : Why do I keep getting a "400 Bad Request" error when trying to update a table style via Ruby's RestClient gem

我正在尝试使用RubygemRestClient为我的一个FusionTables更新样式。这是我的代码:require'rest_client'tableId=''styleId=''key=''table_url="https://www.googleapis.com/fusiontables/v1/tables/#{tableId}/styles/#{styleId}?key=#{key}"update='{"polygonOptions":{"strokeColor":"#ffffff"}}'token='STRINGCONTAININGAUTHORIZATIONTOKEN'R

ruby - 在 AWS Linux 上增加 RestClient/Net::HTTP 中的 connect(2) 超时

我正在使用rest-client发布到一个非常慢的网络服务。我将timeout设置为600秒,并且我已经确认它正在传递给Net::HTTP的@read_timeout和@open_timeout.但是,大约两分钟后,我收到一个低级超时错误,Errno::ETIMEDOUT:Connectiontimedout-connect(2):回溯的相关部分是Operationtimedout-connect(2)for[myhost]port[myport]/Users/dmoles/.rvm/rubies/ruby-2.2.5/lib/ruby/2.2.0/net/http.rb:879:in

ruby - 在 RSpec 中 stub RestClient 响应

我有以下规范...describe"successfulPOSTon/user/create"doit"shouldredirecttodashboard"dopost'/user/create',{:name=>"dave",:email=>"dave@dave.com",:password=>"another_pass"}last_response.shouldbe_redirectfollow_redirect!last_request.url.should=='http://example.org/dave/dashboard'endendSinatra应用程序的post方法使

ruby-on-rails - 如何使用 RestClient 修复 Ruby 中的套接字错误?

我正在使用RestClient在ruby​​类中进行网络调用。每当我未连接到Internet时,我都会收到SocketError。我已经添加了一个救援block来捕获异常,但我仍然无法这样做。错误信息是:SocketError(无法打开到api.something.com:443的TCP连接(getaddrinfo:名称或服务未知))moduleMyProjectclassClientdefget_object(url,params={})response=RestClient.get(url,{params:params})rescueSocketError=>eputs"InSoc

Ruby rest-client 文件上传为具有基本身份验证的多部分表单数据

我了解如何通过Ruby的rest-client使用基本身份验证发出http请求response=RestClient::Request.new(:method=>:get,:url=>@base_url+path,:user=>@sid,:password=>@token).execute以及如何将文件作为多部分表单数据发布RestClient.post'/data',:myfile=>File.new("/path/to/image.jpg",'rb')但我似乎无法弄清楚如何将两者结合起来以便将文件发布到需要基本身份验证的服务器。有谁知道创建此请求的最佳方式是什么?

ruby - 如何为 Ruby 的 RestClient 设置用户代理?

我有兴趣在使用ruby​​RestClientgem时设置我自己的用户代理。http://github.com/archiloque/rest-client但是,我找不到有关如何执行此操作的任何文档。有什么指点吗? 最佳答案 RestClient.get'http://localhost',:user_agent=>"myagent"参见https://github.com/rest-client/rest-client/blob/master/lib/restclient.rb 关于r

ruby - 如何让 Ruby 的 RestClient gem 在发布时尊重 content_type?

例如,在RestClient控制台中:RestClient.post'http://localhost:5001',{:a=>'b'},:content_type=>'application/json'这不会将application/json作为内容类型发送。相反,我看到:Content-Type:application/x-www-form-urlencoded我能够追踪到restclient/payload.rb的变化:classUrlEncoded'application/x-www-form-urlencoded'})endend用super替换super.merge会导致遵守

ruby - 如何调试/显示使用 RestClient 发送的请求

我正在尝试使用RestClient通过post方法访问网络服务。我正在按照指定发送授权token,但我仍然收到403状态错误,这意味着我被禁止使用该api。有什么方法可以让我看到通过httppost发送的请求,以便我可以验证header?我找不到提到如何做到这一点的任何示例或文档?我的代码是这样的:token=get_tokenresponse=RestClient.post"https://api-dev.xxx.com/software/services/search/ABC",:authorization=>"Bearer#{token}" 最佳答案