I've been trying to get a message from a Ruby script to a webapp built with MeteorJS using POST, but I've been facing some issues. There isn't much documentation online about POST and GET method management with Iron Router.
My Ruby script:
meteorUri = URI('http://localhost:3000/newReport');
res = Net::HTTP.post_form(meteorUri, 'message' => 'HelloFromRuby', 'max' => '50')
puts "From Meteor:\t#{res}"
I don't have much experience with Ruby. The above code I got mostly online.
The routing with Iron Router:
Router.route('/newReport/:message', {where: 'server'})
.post( function(message){
Meteor.call('reportInsert', {message: message}, function(error, recordId){
if (error){
alert(error.reason);
} else {
console.log("Inserted " + recordId);
}
});
});
I am trying to make Ruby make a post to http://localhost:3000/newReport
with a message that is supposed to be a string.
The function reportInsert
works, I tested it. The issue seems to be in either making the POST, or receiving it.
Thank you!
Beside using an alert in a server side route, I don't see any issues on Meteor's side. Might want to change it to console.log to see what error are you getting.