How to communicate with Rails App from external C++/C# application using REST?

Hi,

I was wondering how to communicate with my web app from e.g. a C++/C#
application. I know how to use the HTTP Rest methods but was wondering
about the following:

  * How to use POST with the authenticity_token (how do I get the
token?)
  * How to maintain a session (i.e. login and keep the session)?

thanks!

For any method that needs to be POSTed to, you have to turn off the authenticity token check for that action, or that entire controller. This is as simple as:

skip_before_filter :verify_authenticity_token

Maintaining a session is usually done manually, where you have a /login that returns a login token, then every subsequent API request has to include that token or the request is dropped. It's up to the application to keep track of who is logged in and which tokens are valid.

If you want to use a real Rails session, then whatever you use to communicate needs to know how to work with cookies. There are plenty of HTTP client libraries out there, you'll need to find the one that works w/ what you need.

Jason