title: how to set header['content-type']='application/json' in ruby
body: <pre><code>require 'net/http'
  
  require 'rubygems'
  
  require 'json'
  
  url = URI.parse('http://www.xyxx/abc/pqr')
  
  resp = Net::HTTP.get_response(url) # get_response takes an URI object
  
  data = resp.body
  
  puts data
  </code></pre>
  
  <p>this is my code in ruby, resp.data is giving me data in xml form.</p>
  
  <p>rest api return xml data by default , and json if header content-type is application/json.</p>
  
  <p>but i want data in json form.for this i have to set header['content-type']='application/json'.</p>
  
  <p>but i do not know , how to set header with get_response method.to get json data.</p>