tags:

views:

39

answers:

2

I'm trying to post data to a page that handles it for me. I always get following error, however:

ioErrorHandler: [IOErrorEvent type="ioError" bubbles=false cancelable=false eventPhase=2 text="Error #2032: Stream Error. URL: http://localhost:8080/_user/a/ad/admin/message.create.html" errorID=2032] Blockquote

This is the code I have so far. This works fine for GET requests.

        // Object that contains data of the message to be sent
        var toSend:Object = {
            "sakai:type": "internal",
            "sakai:sendstate": "pending",
            "sakai:messagebox": "outbox",
            "sakai:to": "internal:"+sakaimain.gui.dgMessages.selectedItem["to"],
            "sakai:subject": sakaimain.gui.dgMessages.selectedItem["subject"],
            "sakai:body":"testreply with AIR GUI",
            "sakai:previousmessage" : sakaimain.gui.dgMessages.selectedItem["id"]
        };
        // Send message
        // Create loader to load objects
        var loader:URLLoader = new URLLoader();
        // Add event listeners for error and complete events
        loader.addEventListener(Event.COMPLETE, replyMessageCompleteHandler);
        loader.addEventListener(IOErrorEvent.IO_ERROR, replyMessageErrorHandler);
        // Create the request to be done
        var request:URLRequest = new URLRequest("http://localhost:8080/_user/a/ad/admin/message.create.html");
        request.requestHeaders = new Array(new URLRequestHeader("x-sakai-token", sakaimain.token ));
        request.method = URLRequestMethod.POST;
        request.data = toSend;
        // Do the request
        loader.load(request);

Anyone seeing the problem here?

A: 

Check your url first. Thats where the stream error generally comes into play. Make sure you can post to that url outside of your flex application. If you can't, you will probably get a better error message.

What server-side language are you using? Are you really intending to be posting to a .html file?

If the url is accurate, try sending a simpler request with only one key-value pair.

Also, I don't know, but are you sure that it is okay to have a : colon in the form variable name? I would guess that might depend on the server side language you are using.

Ryan Guill
Thanks for your help!The URL is definitely correct, I did a curl request and it posted like it should.There is a Java servlet mapped on that URL (.html).I use colons because that's expected by the back end so I don't have the choice myself.
PhysX
+1  A: 

The problem has been solved. I created URLVariables instead of an object to pass through which fixed the problem.

var urlv:URLVariables = new URLVariables();
urlv["sakai:type"] = "internal";
urlv["sakai:sendstate"] = "pending";
urlv["sakai:messagebox"] = "outbox";
urlv["sakai:to"] = "internal:"+sakaimain.gui.dgMessages.selectedItem["from"];
urlv["sakai:subject"] = sakaimain.gui.dgMessages.selectedItem["subject"];
urlv["sakai:body"] ="testreply with AIR GUI";
urlv["sakai:previousmessage" ] = sakaimain.gui.dgMessages.selectedItem["id"];
PhysX