Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
Locked
0

Request to localhost with URLLoader not working

Explorer ,
May 18, 2019 May 18, 2019

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

TOPICS
Development
305
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
May 19, 2019 May 19, 2019

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); 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
May 19, 2019 May 19, 2019
LATEST

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines