I am making an android application in which I want to post some data to a web server for a chat service. I am thinking of using meteor
which is based on node.js
for the back end as well front end. How do I make a post request to node server in a meteor application from my android device?

- 2,019
- 3
- 21
- 20
2 Answers
Are you sure this is really what you want to do for a chat application?
Don't forget Meteor handles bi-directional communications between the client and server for you.
It's much more likely that you want to simply add the chat text to the database with a Collection insert call, with a Meteor Method call, or look also at Arunoda's meteor-streams smart package.
All 3 options will work faster and be easier to code, than relying on POST requests (don't forget, by default Meteor leverages an open WebSocket connection, when available).

- 1,431
- 15
- 16
-
Thanks for your quick reply @Kinslayer. You are right, ultimately I want to add some chat text to the mongodb table. But can I make a Collection insert call from my native android app If yes then how? I want to update the database from my android app. How do I achieve that? – Annihilator8080 Jul 21 '13 at 17:56
-
Hey, sorry, I missed your reply somehow. The "correct" way to do this is with an Android DDP library. It looks like this has come up before, see: http://stackoverflow.com/questions/10581948/how-can-meteor-be-coupled-to-an-android-app – gadicc Aug 04 '13 at 07:04
You didn't mentioned if you are doing native android or using cordova
for android. If you are using cordova the you can make http calls by Meteor's http API. See docs.
Sample POST request using meteor, you have to import http
package as meteor add http
:
Meteor.http.call("POST",
"http://your.serverurl.com/path",
{data: {some: "json", stuff: 1}},
function (error, result) {
if (result.statusCode === 200) {
//do something
}
});
Or if you are doing native android app. you can do this by Java HttpPost
class. See this example

- 5,602
- 3
- 34
- 46
-
I am making a native android application. But I want to make an http post request to my meteor server. How can I use the `Meteor http package` from inside my android app? The server code sits in some javascript file or probably inside an html document. How do I send data to that server to update the database? – Annihilator8080 Jul 23 '13 at 04:11