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
questo è il mio codice in ruby, risp.data mi sta dando dati in formato xml.come impostare header ['content-type'] = 'application/json' in ruby
rest api restituisce dati xml per impostazione predefinita e json se intestazione content-type è application/json.
ma voglio i dati in forma json. Per questo devo impostare header ['content-type'] = 'application/json'.
ma non so, come impostare l'intestazione con il metodo get_response. Per ottenere dati json.
grazie per l'editing, e renderlo più chiaro. @rubylovely – unknownbits