Flash/Flex sending XML to Rails App

Posted by bdicasa on Stack Overflow See other posts from Stack Overflow or by bdicasa
Published on 2010-04-04T00:49:20Z Indexed on 2010/04/04 0:53 UTC
Read the original article Hit count: 293

Filed under:
|
|
|

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.

© Stack Overflow or respective owner

Related posts about flex

Related posts about flash