Topic: Net::HTTP not working with https?
I made a method to request and parse json. It works with one of the api's I connect to. However, it does not work with the gist api. I think it is because the gist api uses ssl (https). Any help to modify my code to work with both http and https? Is that even the issue?
JSON::ParserError in PagesController#index 743: unexpected token at '<html> <head><title>400 The plain HTTP request was sent to HTTPS port</title></head> <body bgcolor="white"> <center><h1>400 Bad Request</h1></center> <center>The plain HTTP request was sent to HTTPS port</center> <hr><center>nginx/1.0.4</center> </body> </html> '
def json_api_pull(url) resp = Net::HTTP.get_response(URI.parse(url)) data = resp.body result = JSON.parse(data) return result end