HTTParty parameter setting is not working properly

I am setting up an application that can handle LastFM API requests. These are simple receive requests, and I am using the HTTParty stone.

My function is this:

def get_albums self.class.base_uri "http://ws.audioscrobbler.com/2.0/" options = { :user => "Gerard1992", :method => "user.gettopalbums", :api_key => Constants::LASTFM_API_KEY, :format => "json" } puts options.to_query self.class.get "/?#{options.to_query}", {} #options don't work end 

This code snippet shown above works. A get request returns a set of JSON. My problem is that this /?#{options.to_query} doesn't look so neat. And also the actual (now empty {} ) parameter does not matter. How to make the HTTParty parameter parameter work as it should?

This is what I tried, but both cases failed:

 self.class.get "/", options self.class.get "/", options => options 

I appreciate the help.

+8
source share
2 answers

The correct option for request parameters in HTTParty is :query , so you want:

 self.class.get "/", query: options 

You can see all the available options in the documents .

+22
source

Send: verify => false in hash parameters

0
source

All Articles