Copy link to clipboard
Copied
Hello,
I'm trying to get a request to a localhost url to work but it doesn't seem to work with URLLoader though it does seem to work with the mx.rpc.http.HTTPServ class.
The following works
var httpServ:HTTPService = new HTTPService();
httpServ.method = "POST";
httpServ.contentType = "application/xml";
httpServ.url = "http://localhost:1813";
httpServ.send(requestData);
While this does not
var urlRequest:URLRequest = new URLRequest();
urlRequest.contentType = "application/xml";
urlRequest.url = "http://localhost:1813";
urlRequest.method = "POST";
var urlLoader:URLLoader = new URLLoader();
urlLoader.data = requestData;
urlLoader.load(urlRequest);
Can anyone tell me how to get the latter to work or why it's not working? It's giving me an IOErrorEvent. requestData is simply the request body in XML format
[IOErrorEvent type="ioError" bubbles=false cancelable=false eventPhase=2 text="Error #2032: Stream Error. URL: http://localhost:1813" errorID=2032]
Thanks,
Kyle
Copy link to clipboard
Copied
Try this one:
var urlRequest:URLRequest = new URLRequest();
urlRequest.url = "http://localhost:1813";
urlRequest.method = URLRequestMethod.POST;
var headers:Array = [
new URLRequestHeader("contentType", "application/xml")];
urlRequest.requestHeaders = headers;
urlRequest.data = requestData;
var urlLoader:URLLoader = new URLLoader();
urlLoader.load(urlRequest);
Copy link to clipboard
Copied
Hi,
Thanks for the response.
I had actually tried that method first and when it didn't work, I saw the contentType property and attempted to use that. Neither method work unfortunately. I get the same error using URLRequestHeader as well
Kyle
Find more inspiration, events, and resources on the new Adobe Community
Explore Now