views:

708

answers:

2

I am having trouble getting my flex app to send a POST request to my Rails app. It seems to always send GET.

This is my service declaration:

<mx:HTTPService id="add_email_service" showBusyCursor="true" result="parseJoinResult();" fault="onJoinFault(event)" useProxy="false" />

In my application init function, I set the method to POST:

add_email_service.url = join_url;
add_email_service.method = "POST";

However, my Rails app still sees the request as a post request when I send it. I know this because if I require the request to be POST in my routes.rb file:

# RESTful API for joining a mailing list
  map.connect 'mailing_lists/join/:id', 
      :controller => 'mailing_lists', 
      :action => 'join', 
      :conditions => { :method => :post}

the request faults and I can see in my dev log :

"Processing ApplicationController#index (for 127.0.0.1 at 2009-04-23 14:25:35) [GET], ActionController::MethodNotAllowed (Only post requests are allowed.):"

Does anyone know why this is happening?

+1  A: 

Older versions of the Flash Player (in some browsers) would automatically switch your request from POST to GET if there were no variables being sent.

Try adding a param to your request and see if that fixes it.

Integrating Flash Player with Restful Rails?

Get ready for some other issues too:

  1. The Flash Player can only accept HTTP status code of 200, everything else throws an exception and prevents you from getting at the message body.
  2. You can't send PUTS or DELETE HTTP methods
Luke Bayes
thanks for the info. i disabled the post condition a while ago to put this bug aside, and then when I enabled it the bug "disappeared". so that may very well have been the issue. bummer about only accepting 200 status codes! can it detect the difference between unauthorized, unprocessable, internal server error, etc.?
Tony
A: 

I believe it's literally 200 only.

Luke Bayes