Sending Json Form from Flash AS3 Sending Json Form from Flash AS3 json json

Sending Json Form from Flash AS3


The error is, because you are passing incorrect string to URLVariables constructor. Do not use URLVariables. Instead pass data as string: request.data=JsonObj;


Below is the code I am using to consume REST Web service and pass json parameter to service it shows. Error #2032: Stream Error.Andy idea what is going wrong

var ldr:URLLoader = new URLLoader();ldr.dataFormat = URLLoaderDataFormat.TEXT;var strData:String = "{\"gparam\": [ {\"productid\": \"" + productId + "\"},{\"message\": \"" + mesage + "\"},{\"googleappid\": \"" + googleappid + "\"},{\"senderid\": \"" + senderid + "\"},{\"appname\": \"" + appName + "\"},{\"userid\": \"" + userId + "\"},{\"receiverid\": \"" + receiverId + "\"} ]}";var hdr:URLRequestHeader = new URLRequestHeader("Content-type", "application/json");var req:URLRequest = new URLRequest("http://localhost/AndroidGCM/GCMNotification.svc/SendGCM");req.requestHeaders.push(hdr);req.method = URLRequestMethod.POST;req.data = strData;trace("data: " + req.data);ldr.addEventListener(Event.COMPLETE,onComplete);ldr.addEventListener(IOErrorEvent.IO_ERROR , onError);ldr.addEventListener(SecurityErrorEvent.SECURITY_ERROR ,onSecurityErr);ldr.load(req);function onComplete(e:Event):void{    trace("LOAD COMPLETE: " + ldr.data);TextField(parMC.getChildByName("txtCheck")).appendText("\n LOAD COMPLETE: " + ldr.data);}function onSecurityErr(e:SecurityErrorEvent):void{    trace("error: " + e.text );}function onError(e:IOErrorEvent):void{    trace("error: " + e.toString());}