Last active
January 22, 2017 14:42
-
-
Save madhikarma/68d2e80ea5194b1ce30e41f93b85c5d6 to your computer and use it in GitHub Desktop.
Ruby HTTP request
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# To use save this file, open a terminal at its location and execute `ruby request.rb` | |
require 'net/http' | |
require 'json' | |
url = "https://api.spotify.com/v1/search?type=artist&q=bonobo" | |
uri = URI(url) | |
request = Net::HTTP::Get.new(uri) | |
request["MyCustomHeader"] = "abcde" | |
Net::HTTP.start(uri.host, uri.port, :use_ssl => true) do |http| | |
response = http.request(request) | |
puts(response.body) | |
json = JSON.parse(response.body) | |
puts(json) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment