2

I have a script that goes into Fedex Billing each week when they mail me my invoice, digs out information and posts it to xpenser.com. After the recent Fedex Billing site redesign, when I run this code:

  agent = Mechanize.new
  page = agent.get 'http://fedex.com/us/fcl/pckgenvlp/online-billing/'
  form = page.form_with(:name => 'logonForm')
  form.username = FEDEX['username']
  form.password = FEDEX['password']
  page = agent.submit form
  pp page

I receive this error:

Mechanize::ResponseCodeError: 405 => Net::HTTPMethodNotAllowed

I see there is a javascript auth function that seems to build a URL that sets hidden variables. I've tried to pass various combinations of variable strings in without success.

While Mechanize doesn't support javascript, it will pass in variable strings and if you hit the correct one, you can auth that way. I'm hoping to do that here.

johnnygoodman
  • 475
  • 6
  • 19
  • I advise you use firebug firefox plugin to trace the actual query (and find set of all required params) and after that improve your ruby code. – taro May 10 '11 at 18:45
  • you need set form.action manually and also those params: appName, step3URL, afterwardsURL, returnurl. see function CallLogin() for details. – taro May 10 '11 at 19:11

1 Answers1

0

Using mechanize-1.0.0 the following works:

  agent = Mechanize.new
  page = agent.get 'http://fedex.com/us/fcl/pckgenvlp/online-billing/'
  form = page.form_with(:name => 'logonForm')
  form.username = FEDEX['username']
  form.password = FEDEX['password']
  form.add_field!('field_name', 'Page$2')
  page = agent.submit form
  pp page

try this. it may help you

Hitesh
  • 815
  • 1
  • 6
  • 11