To make an HTTP request with URL parameters in Ruby, you can use the Net::HTTP
module. Here is an example of how to do it:
main.rb219 chars9 lines
In this example, we are making a request to http://example.com/search
with two URL parameters: :q
and :page
. The URI
module is used to encode the parameters and add them to the URI. Then Net::HTTP.get_response()
is used to send the request and receive the response. Finally, we print the response body if the response was successful.
Note that this example uses a GET request, but you can also use POST or other HTTP methods with parameters. Additionally, you may need to add headers or authentication information depending on the API you are working with.
gistlibby LogSnag