require 'net/http' require 'rubygems' require 'json' url = URI.parse('http://www.xyxx/abc/pqr') resp = Net::HTTP.get_response(url)
this is my ruby ββcode, resp.data gives me data in xml form.
rest api returns xml data by default, and json if the header content type is application / json.
but i want the data in json form.for this i have to set header ['content-type'] = 'application / json'.
but I do not know how to set the header using the get_response method. Get json data.
source share