AS3: Having issues doing a POST with URLLoader/URLRequest?

This issue was killing me. We’re in the process of upgrading our codebase from Actionscript 1 (yes that old clunky thing) to Actionscript 3 (auto-completion heaven!). ¬†And for the life of me, I couldn’t figure out how to get POST with URLLoader working. I was close to convinced that AS3 had a core bug (ah… don’t we engineers love throwing the blame to the framework).

I found a whole bunch of posts of people who had trouble doing POST with actionscript 3, but in all the threads I read, they got it working! But I just couldn’t.

I left the issue for a while (coz, you know, there are 10,000 things on my plate, but we all know about that), but it came to the point where I had to figure it out or our development would stall.

It’s really simple. I guess my poor knowledge of how HTTP works with respect to content headers and all that had a big part to do with the problem.

I had this line:

urlRequest.contentType = “text/xml”;

This line shouldn’t be there when doing a POST with URLLoader. Problem solved.