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

**URL:** <https://www.ruby-forum.com/t/how-to-communicate-with-rails-app-from-external-c-c-application-using-rest/190992>\
**Category:** Rails\
**Created:** [July 2, 2010, 1:33am UTC](https://www.ruby-forum.com/t/how-to-communicate-with-rails-app-from-external-c-c-application-using-rest/190992 "2010-07-02T01:33:17Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gerwin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/a6a055/32.png) [@Gerwin](https://www.ruby-forum.com/u/Gerwin)\
**Post date:** [July 2, 2010, 1:33am UTC](https://www.ruby-forum.com/t/how-to-communicate-with-rails-app-from-external-c-c-application-using-rest/190992/1 "2010-07-02T01:33:17Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![Gerwin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/a6a055/32.png) [@Gerwin](https://www.ruby-forum.com/u/Gerwin)\
**Post date:** [July 2, 2010, 2:28am UTC](https://www.ruby-forum.com/t/how-to-communicate-with-rails-app-from-external-c-c-application-using-rest/190992/2 "2010-07-02T02:28:54Z")

</div>

On Jul 1, 2010, at 7:31 PM, Gerwin wrote:

> thanks!
> 
> –  
> You received this message because you are subscribed to the Google G. “Ruby on Rails: Talk” group.  
> To post to this group, send email to removed\_email\_address@domain.invalid.  
> To unsubscribe from this group, send email to removed\_email\_address@domain.invalid.  
> For more options, visit this group at [http://groups.google.com/group/rubyonrails-talk?hl=en](http://groups.google.com/group/rubyonrails-talk?hl=en).

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
