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
127
votes
2 answers

POST JSON to API using Rails and HTTParty

I would like for a user within my ruby on rails app to be able to submit a ticket to my external ticket management system, squishlist.com. They have an api and instructions as follows. You need to authenticate and get a token and then submit the…
Homer Jon
  • 4,463
  • 3
  • 15
  • 9
84
votes
2 answers

How to use basic authentication with httparty in a Rails app?

The command line version of 'httparty' with basic authentication works simple and great: httparty -u username:password http://example.com/api/url But now I'm looking for the way I can add the basic auth to a HTTParty.get call from within a Rails…
Dr.Bob
  • 1,152
  • 1
  • 8
  • 10
79
votes
3 answers

How can I handle errors with HTTParty?

I'm working on a Rails application using HTTParty to make HTTP requests. How can I handle HTTP errors with HTTParty? Specifically, I need to catch HTTP 502 & 503 and other errors like connection refused and timeout errors.
preethinarayan
  • 803
  • 1
  • 6
  • 6
61
votes
2 answers

Passing headers and query params in HTTparty

How to pass query params and headers in post method using HTTparty. I am doing as follows But it throws query = {:method => "neworder", :nonce => 1404996028, :order_type => "buy", :quantity=>1,:rate=>1} headers = {:key=> "87819747209090199871234",…
Sam
  • 5,040
  • 12
  • 43
  • 95
58
votes
4 answers

How do I make HTTParty ignore SSL?

I'm using a local server to test an application, and make requests to that server from my own machine. The test server's SSL is bad, and HTTParty throws errors because of that. From what I read, HTTParty should ignore SSL by default, but when I try…
Jasper Kennis
  • 3,225
  • 6
  • 41
  • 74
36
votes
3 answers

httparty: how to log request?

How do I log requests being sent with with httparty? HTTParty.post( @application_url, :headers => { "Accept" => "application/json", "Content-Type" => "application/json; charset=utf-8" }, …
Eric Francis
  • 23,039
  • 31
  • 88
  • 122
22
votes
1 answer

how to find response code after httparty form POST

I have made a POST to a site using Httparty with the following code: HTTParty.post("http://example.com", :body => application_hash.to_json, :headers => {'Content-Type' => 'application/json'}) How can I check what the response code was for this…
dan-mi-sun
  • 551
  • 2
  • 4
  • 18
22
votes
1 answer

Ruby error Net::ReadTimeout

I am making a series of API calls using httparty. The first two API calls succeed, but the third one fails. It pauses for about 60 seconds (default timeout period) and then returns this…
Luigi
  • 5,443
  • 15
  • 54
  • 108
21
votes
3 answers

How do I inspect the full URL generated by HTTParty?

I want to look at the full URL the HTTParty gem has constructed from my parameters, either before or after it is submitted, it doesn’t matter. I would also be happy grabbing this from the response object, but I can’t see a way to do that…
Leo
  • 4,217
  • 4
  • 25
  • 41
19
votes
6 answers

Trouble including httparty in ruby on rails

I've been trying to use HTTParty in my rails code sudo gem install httparty From the command line I can now successfully do httparty "http://twitter.com/statuses/public_timeline.json" When I try this in my rails app require 'rubygems' require…
AllDayer
  • 993
  • 1
  • 9
  • 20
19
votes
2 answers

HTTParty and authorization via token

Somehow HTTParty returns 401 where CURL works fine. Not sure how to pass token in headers. Working (200): curl http://localhost:3020/api/products -H 'Authorization: Token token="111"' Not working…
olimart
  • 1,529
  • 3
  • 17
  • 32
18
votes
3 answers

How to switch base_uri with httparty

I am trying to pass a parameter to a login method and I want to switch the base uri based on that parameter. Like so: class Managementdb include HTTParty def self.login(game_name) case game_name when "game1" …
Joseph Le Brech
  • 6,541
  • 11
  • 49
  • 84
18
votes
2 answers

Changing Content-Type to JSON using HTTParty

I am trying to use Ruby on Rails to communicate with the Salesforce API. I can fetch data easily enough but I am having problems posting data to the server. I am using HTTParty as per Quinton Wall's post here:…
GrahamJRoy
  • 1,603
  • 5
  • 26
  • 56
17
votes
4 answers

Parsing JSON in Controller w/ HTTParty

In my controller I have the following code... response = HTTParty.get('https://graph.facebook.com/zuck') logger.debug(response.body.id) I am getting a NoMethodError / undefined method `id' If I do... logger.debug(response.body) It outputs as it…
gbdev
  • 968
  • 2
  • 11
  • 25
16
votes
3 answers

ruby httparty get response url or id after post

How can I get the response url or id from a rails project with httparty in a separate script after doing a post? ruby script: HTTParty.post('http://localhost:3000/change_logs', parameters) response.body and all the others ones do not show the url…
nictrix
  • 1,483
  • 1
  • 17
  • 34
1
2 3
41 42