So I needed to create a monitoring app that would hit a RESTful interface that required authentication. The only way to hit this RESTful service was to POST to a login page and then manage the authentication cookies for the remainder of the session. And I needed to get this done fast.
This is why I love NodeJS. NoneJS is more than a totally awesome web app platform. It makes for a great client application too.
NodeJS for the command line
The following is the basic code for kicking of an https request. The options argument contains the url, method, and any headers (including cookies). The data argument is for any data that needs to be POSTed with the request. (Make sure you set the appropriate headers for the data like content-type).
The magic is in the processResponse function. This is where we capture the cookie and store it for…
View original post 40 more words