Posting JSON data to another host

Hello Team,

I have a rails web application and have to post a json to the host
below.

Presently i am struggling.

Can you please help us a with a sample rails controller method to push
this below notification.

POST
/push?api_key=31fbfefcd4baa21221545c1233cf2631d9e3eca7f6e76b6c486144c115002de0
HTTP/1.1

Host: https://pushy.me

Content-Type: application/json

Connection: close

Content-Length: 82

{“registration_ids”:[“d62d6163f916d15eed601b”], “data”:{“message”:“Hello
World!”}}

On Sunday, August 9, 2015 at 10:36:12 AM UTC+1, Zed wrote:

Can you please help us a with a sample rails controller method to push
this below notification.

net/http is a rather confusing bit of ruby. You may find using a higher
level client such as rest client or faraday makes things easier but
something like the below should do it

req = Net::HTTP::Post.new(uri)
req.body =’…’
req.content_type = ‘application.json’

res = Net::HTTP.start(uri.hostname, uri.port) {|http|
http.request(req)
}

Fred