I'm trying to send some XML to a rails app in Flex. I'm using the URLRequest and URLLoader objects. However, I'm having trouble determining how to send the XML and _method parameter to the rails app using these flash objects. Below is how I'm currently trying to achieve this.
var request:URLRequest = new URLRequest();
request.method = URLRequestMethod.POST;
request.data = new Object();
request.data.xml = Blog.xml.toXMLString();
request.contentType = "text/xml";
var loader:URLLoader = new URLLoader();
loader.addEventListener(Event.COMPLETE, saveCompleteHandler);
var saveUrl:String = "";
saveUrl = BASE_URL;
if (Blog.isNewBlog)
{
// Set the rails REST method.
request.data._method = "POST";
saveUrl += "blogs.xml";
}
else
{
// Set the rails REST method.
request.data._method = "PUT";
saveUrl += "blogs/" + Blog.id.toString() + ".xml";
}
request.url = saveUrl;
//trace(request.data.toString());
loader.load(request);
However the only data that is getting sent to the server is [Object object]. If some one could let me know where I'm going wrong I'd greatly appreciate it. Thanks.