httparty

Capture specific request with HTTParty

冷暖自知 提交于 2019-12-03 16:22:09
问题 I would like to capture the full request (raw_request -- what went over the wire) for a given action without using a proxy. I am aware of the debug_output method on the Class, and that might be part of the solution. But unclear on how to set it on a per request basis. Consider the following ... @response = HTTParty.post(@job.callback_url, body: @job.to_json) notification = Notification.new notification.response_body = @response.body notification.response_code = @response.code notification

Sending Form data to remote rails application using Httparty

瘦欲@ 提交于 2019-12-02 17:25:19
问题 I am new to Httparty. I have a simple rails application with its default methods, new, create for creating a new Model object. So basically if you consider the article controller as an example. First new method instantiates the Model by Model.new and then the partial form is called which asks user for data and upon submit it calls the controller create method. But my problem is that I want to call these methods remotely from the different rails application using Httparty. So I first call the

Sending Form data to remote rails application using Httparty

谁说胖子不能爱 提交于 2019-12-02 13:41:31
I am new to Httparty. I have a simple rails application with its default methods, new, create for creating a new Model object. So basically if you consider the article controller as an example. First new method instantiates the Model by Model.new and then the partial form is called which asks user for data and upon submit it calls the controller create method. But my problem is that I want to call these methods remotely from the different rails application using Httparty. So I first call the new method, it then instantiates the remote model and returns it to the remote app. In the remote app I

Cannot get anything in https protocol with curl, httparty or net::http

好久不见. 提交于 2019-12-02 07:11:25
问题 I am having trouble to get anything using https. I can't fetch anything like: curl -k https://graph.facebook.com or uri = URI('https://graph.facebook.com/davidarturo') Net::HTTP.get(uri) I get: error: EOFError: end of file reached Also there is no luck with httparty and https 回答1: As you use 'https' protocol, you must explicitly tell about it in case of using net/http library: require 'net/http' uri = URI('https://graph.facebook.com/davidarturo') http = Net::HTTP.new(uri.host, uri.port) http

Cannot get anything in https protocol with curl, httparty or net::http

无人久伴 提交于 2019-12-02 07:05:11
I am having trouble to get anything using https. I can't fetch anything like: curl -k https://graph.facebook.com or uri = URI('https://graph.facebook.com/davidarturo') Net::HTTP.get(uri) I get: error: EOFError: end of file reached Also there is no luck with httparty and https As you use 'https' protocol, you must explicitly tell about it in case of using net/http library: require 'net/http' uri = URI('https://graph.facebook.com/davidarturo') http = Net::HTTP.new(uri.host, uri.port) http.use_ssl = true if uri.scheme == 'https' http.start do |h| response = h.request Net::HTTP::Get.new(uri

Extracting values from a hash

邮差的信 提交于 2019-12-02 04:22:27
问题 Hello Im using HTTParty to call for a remote json file that I need to extract the URL's to use in one of my tests.. the json format goes something like: "manifest" : { "header" : { "generated" : "xxxxxxxxxxxxxxx", "name" : "xxxxxxxxxxx", "version" : "1.0.0" }, "files" : [ { "file" : "blimp.zip", "url" : "http://www.xxx.xx/restaurants_blimp.zip", "checksum" : "ee98c9455b8d7ba6556f53256f95" }, { "file" : "yard.zip", "url" : "www.xxx.xx/yard.zip", "checksum" : "e66aa3d123f804f34afc622b5" } on

Extracting values from a hash

北城余情 提交于 2019-12-02 02:33:58
Hello Im using HTTParty to call for a remote json file that I need to extract the URL's to use in one of my tests.. the json format goes something like: "manifest" : { "header" : { "generated" : "xxxxxxxxxxxxxxx", "name" : "xxxxxxxxxxx", "version" : "1.0.0" }, "files" : [ { "file" : "blimp.zip", "url" : "http://www.xxx.xx/restaurants_blimp.zip", "checksum" : "ee98c9455b8d7ba6556f53256f95" }, { "file" : "yard.zip", "url" : "www.xxx.xx/yard.zip", "checksum" : "e66aa3d123f804f34afc622b5" } on irb I can get all the sub hashes inside example: ['manifest']['files'] and I can only get the url if I

Unescaping characters in a string with Ruby

孤者浪人 提交于 2019-12-01 09:13:20
Given a string in the following format (the Posterous API returns posts in this format): s="\\u003Cp\\u003E" How can I convert it to the actual ascii characters such that s="<p>" ? On OSX, I successfully used Iconv.iconv('ascii', 'java', s) but once deployed to Heroku, I receive an Iconv::IllegalSequence exception. I'm guessing that the system Heroku deploys to does't support the java encoder. I am using HTTParty to make a request to the Posterous API. If I use curl to make the same request then I do not get the double slashes. From HTTParty github page: Automatic parsing of JSON and XML into

Unescaping characters in a string with Ruby

青春壹個敷衍的年華 提交于 2019-12-01 06:17:16
问题 Given a string in the following format (the Posterous API returns posts in this format): s="\\u003Cp\\u003E" How can I convert it to the actual ascii characters such that s="<p>" ? On OSX, I successfully used Iconv.iconv('ascii', 'java', s) but once deployed to Heroku, I receive an Iconv::IllegalSequence exception. I'm guessing that the system Heroku deploys to does't support the java encoder. I am using HTTParty to make a request to the Posterous API. If I use curl to make the same request

'Nesting too deep' error while retrieving JSON using HTTParty

放肆的年华 提交于 2019-12-01 06:15:19
I am writing a very simple proxy wrapper for the reddit api so I can make cross domain JSONP requests (reddit does not allow JSONP calls to my knowledge). I am using the HTTParty gem to make the call out and retrieve the response, which I immediately render out as json. I am retrieving the subreddit json perfectly fine so far with this as my route: match "r/:name" => "api#subreddit" ... and this as my controller action: def subreddit render :json => HTTParty.get("http://www.reddit.com/r/" + params[:name] + "/.json"), :callback => params[:callback] end As an example, the JSON that comes back is