Senden einer Post-Anfrage mit net / http
Ich muss Daten in JSON an eine andere App senden, die auf demselben Computer ausgeführt wird.
Ich sende Anfrage gerne so (Schienen 3.2.13)
data = { //some data hash }
url = URI.parse('http://localhost:6379/api/plans')
resp, data = Net::HTTP.post_form(url, data.to_JSON )
p resp
p data
{ resp: resp, data: data.to_JSON }
Aber ich versteheNet::HTTPBadResponse (wrong status line: "-ERR unknown command 'POST'"):
Wie kann ich dieses Problem lösen?
Update 1
Aktualisiert meinen Code als @ Raja-d vorgeschlagen
url = URI.parse('http://localhost:6379/v1/sessions')
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
resp, data = Net::HTTP.post_form(url, data)
p resp
p data
Aber ich bekomme immer noch FehlerNet::HTTPBadResponse (wrong status line: "-ERR unknown command 'POST'"):