getting csv data from RTC using form based authentication

I’ve been playing with ways to get CSV data from an RTC server.  Here’s how to get the CSV file related to a query when the server uses forms based authentication.  The following code snippet shows how to get the CSV file associated with an RTC query.

Apart from knowing your userid and password you also need to know the query id.  That’s a lovely string that looks something like  _UkgjwLDcEeO2Eca4475iNQ and usually makes up a portion of the RTC query url.

Assuming you’ve got them then this sort of  code does the trick.

require 'mechanize'
require 'nokogiri'
require 'linkeddata'


page=mechanize.get(host+'/resource/itemOid/'+queryid+'?_mediaType=text/csv'),{ 'j_username' => userid , 'j_password' => password}).body

puts data

About spoole167

I'm DevOps practitioner (whatever that means), a long time Java developer and Open Source advocate. I speak and present at conferences whenever I have something to say on technical and software engineering topics. I work for IBM but this blog is all my own work.
This entry was posted in CODE, RUBY, Uncategorized and tagged . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s