Questions tagged [httparty]

HTTParty is a Ruby gem written by John Nunemaker focused on the consumption of web services and APIs.

HTTParty is a Ruby gem written by John Nunemaker focused on the consumption of web services and APIs. It boasts a very readable DSL and out-of-the-box support for JSON, HTML and XML.

For more information refer to: It's an HTTParty and Everyone Is Invited!

621 questions
5
votes
3 answers

Parsing HTTP header 'set-cookie' with HTTParty

I'm using HTTParty for making HTTP requests and for using REST APIs. Now I want to re-use cookies set by a login page I called via POST. class SomeImporter include HTTParty def self.login response =…
Sven R.
  • 1,049
  • 17
  • 24
5
votes
1 answer

How to correctly replicate response body of an HTTParty requests' response for webmock stub

I have an HTTParty request with response of the form: # [{"id"=>"11111", "name"=>"foo", "reference"=>nil}, {"id"=>"22222", "name"=>"bar", "reference"=>nil}] }, …
x6iae
  • 4,074
  • 3
  • 29
  • 50
5
votes
1 answer

Very Basic Rails 4.1 API Call using HTTParty

Relatively new to Rails. I am trying to call an API and it's supposed to return a unique URL to me. I have HTTParty bundled on my app. I have created a UniqueNumber controller and I have read through several HTTParty guides as far as what I want but…
keith
  • 651
  • 2
  • 6
  • 10
5
votes
3 answers

Encoding 4 byte UTF-8 character to JSON from Rails produce invalid character

I have a web service in rails (3.2.19) that encode a JSON to be read by some iOS or Android apps. The json might contain any characters, but it seems to fail every time I use a 4 bytes UTF8 character such as : it produce instead \uf4a9 aka . In…
Antzi
  • 12,831
  • 7
  • 48
  • 74
5
votes
1 answer

OpenSSL::SSL::SSLError: hostname does not match the server certificate

All of sudden today morning my HTTP client (HTTParty) threw an error OpenSSL::SSL::SSLError: hostname does not match the server certificate Firstly I'm not able to understand which so today we have been make that api call almost all day number times…
Ratatouille
  • 1,372
  • 5
  • 23
  • 50
4
votes
3 answers

'Nesting too deep' error while retrieving JSON using HTTParty

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…
Evan
  • 1,737
  • 1
  • 19
  • 32
4
votes
1 answer

HTTParty and text/xml

I'm trying to make a POST request using HTTParty, in which I need the content-type to be text/xml. How can I make that happen? Right now the API I'm calling is complaining I'm not sending any xml. If I call it using curl I get the same error, unless…
Claudio Lassala
  • 271
  • 3
  • 15
4
votes
1 answer

How to stub a HTTParty request inside a method for testing?

I have created a function that makes a HTTParty get request. It raises a custom error message that i need to test. I tried to stub the request using Webmock in the test but it is raising a . How can i stub the get request if the…
sparkstar
  • 593
  • 1
  • 7
  • 14
4
votes
1 answer

Failed to open TCP connection to :80 HTTParty gem

So in my course on Coursera I'm required to build this rather simple aplication to obtain and display an array from an external api. I'm using the ruby on rails framework. (I'm using windows 10) Controller - class CoursesController <…
Mihir Deshpande
  • 105
  • 2
  • 2
  • 5
4
votes
2 answers

Is it possible to work with HTTParty request results as an object

I wonder if it possible to work with HTTParty request results as an object. Currently I use string keys to access to values of result: result["imageurl"] or result["address"]["street"] If i were in JavaScript I could simply use: result.imageurl or…
Alexey Zakharov
  • 24,694
  • 42
  • 126
  • 197
4
votes
1 answer

how to mimic a curl action with httparty

I have loved using HTTParty in the past, but at the moment I'm coming up against a problem I haven't been able to figure out yet. The API I'm interacting with is successfully contacted like so: curl -X PUT -d 'id=1175600;status=0'…
4
votes
1 answer

SendGrid add multiple email addresses to Marketing Email API

I'm having some real difficultly trying to send multiple email addresses in json to the sendgrid API. Here is my code that works for one email address: @result = HTTParty.post("https://api.sendgrid.com/api/newsletter/lists/email/add.json", :body =>…
David
  • 3,166
  • 2
  • 30
  • 51
4
votes
1 answer

Why do I get IO::EAGAINWaitReadable with HTTParty?

Bugsnag reports that from time to time IO::EAGAINWaitReadable exception is raised in production. IO::EAGAINWaitReadable: Resource temporarily unavailable - read would block The exception is raised on HTTP request via HTTParty, ultimately leading to…
Nowaker
  • 12,154
  • 4
  • 56
  • 62
4
votes
1 answer

Is their a way to create Dummy Response with 500 code in HTTParty

Here my HTTParty code response = HTTParty.post(api_url,body: form_data,timeout: 5) rescue Timeout::Error ## create dummy response with 500 error code response = HTTParty::Response.new() ensure response all I'm…
Ratatouille
  • 1,372
  • 5
  • 23
  • 50
4
votes
1 answer

Getting Net::ReadTimeout: Net::ReadTimeout error in httparty

I have used httparty gem in rails 4 app while I am posting to an api the query is running in the server, but my console breaks with the error Net::ReadTimeout: Net::ReadTimeout. FYI: I am posting the data to create a record in different site with…
Debadatt
  • 5,935
  • 4
  • 27
  • 40