FAQ Database Discussion Community


HTTParty.head retrieves full response for MP3

ruby-on-rails,httparty
I'm using HTTParty to check the health of some mp3s, so I just want to make a head request and see the response code. However when I use HTTParty.head on mp3s I'm receiving the full response. e.g., response = HTTParty.head("https://archive.org/download/is-los-angeles-still-a-city-of-quartz.LYaAW6.popuparchive.org/ww_2015-06-18-202413.6929.mp3") Using curl works as expected curl -IL https://archive.org/download/is-los-angeles-still-a-city-of-quartz.LYaAW6.popuparchive.org/ww_2015-06-18-202413.6929.mp3...

Rails: How to get a http request with header? (Product Hunt API)

ruby-on-rails,httparty
I'm trying to use Product Hunt's API to get its daily posts. This is what I endup with task :fetch_product_hunt => :environment do query = "http://api.producthunt.com/v1/posts" access_token = `My API Key` response = HTTParty.get(query, :headers => {'Accept' => 'application/json', 'Content-Type' => 'application/json', 'Authorization' => access_token, 'Host' => 'api.producthunt.com'}).body decode_response =...

Getting Webmock to stub HTTParty requests

ruby-on-rails,ruby,httparty,webmock
I am having trouble getting Webmock to work. I am using HTTParty to make GET requests. I would like to have the following request return an error: require 'spec_helper' require 'api_parser' require 'httparty' describe ApiParser do describe "#get_data" do it "returns data" do stub_request(:get, "congress.api.sunlightfoundation.com").to_return(:status => [401, "Forbidden"]) puts HTTParty.get...

Ruby API Call Page Issue

ruby-on-rails,ruby,json,api,httparty
This might be a basic issue but very common so it might be helpful to other people in the future. I use HTTParty to make a get request to an API, which returns some information, something like this: { datapath: "blah-blah.blah.blah", success: true, info: { row_limit: 500, total_results: 2700, total_pages:...

bad URI(is not URI?): {“message”:“d64”,“type”:“success”}

ruby-on-rails,api,httprequest,httpresponse,httparty
Am using httparty to send API request, I want to get output response after i sent request, url = HTTParty.post("https://example.com/api/sendhttp.php", :query => { :authkey => "authkeyvalue", :mobiles => mobileNos, :message => messages, :sender => "senderid", :route => "routeid", :response => 'json' }) response = HTTParty.get(url) puts response.body, response.code, response.message, response.headers.inspect...

Ruby HTTParty soundcloud gem error

ruby,soundcloud,httparty
I was experimenting with the soundcloud gem and suddenly I always get an error with every request I make. For example this following code: require 'soundcloud' client = SoundCloud.new(:client_id => MY_CLIENT_ID) track_url = 'https://soundcloud.com/sohight/sohight-cheevy-money-is-love-out-now' track = client.get('/resolve', :url => track_url) puts track.genre Anyone knows why I get this error? /Users/angel/.rvm/gems/ruby-2.2.0/gems/httparty-0.13.4/lib/httparty/hash_conversions.rb:33:in...

How to deauthorize/disconnect Stripe Connect accounts in Rails

ruby-on-rails,curl,stripe-payments,httparty,stripe-connect
I was looking for quite a long time for a good example on how to de-authorize / disconnect a Stripe Connect account in my Rails app. Perhaps for those that are well versed in making external POST requests, this is trivial, but I'm new and this seemed so hard for...

What does this code, that looks like JavaScript object do?

ruby-on-rails,ruby,httparty
@options = { query: {site: service, page: page} } What does this do? In javascript this, I think would be object definition, however I cannot find what exactly it is in ruby. This would be the full code: class StackExchange include HTTParty base_uri 'api.stackexchange.com' def initialize(service, page) @options = {...

Ruby no method error with HTTParty

ruby,http,post,rspec,httparty
I am trying to make a post request in Ruby and I am getting inconsistent behaviour. I am currently using ruby-2.0.0-p598 on OSX. When using PRY and I type the following post command: HTTParty.post(@base_uri + '/method/?argument1&api_key=' + @api_key) I get a successful respond from the API. However when I run...

How do I inspect the full URL generated by HTTParty?

ruby-on-rails,ruby,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 either. (Bit of background)...

HTTParty parsing JSON in Rails

ruby-on-rails,ruby,httparty
I have a URL that displays JSON holding info for 400 YMCA locations. My goal is to be able to pull latitude and longitude for each location in order to display the points on a map. I was playing around with HTTParty and just wanted to start by displaying only...