Processing
 

Sending Json Form from Flash AS3

07/03/2012 05:45#1

meghana

Member

Joined at: 9 months ago

Post: 4

Thank: 0

Thanked: 0

i am having one form accepting json post in Asp.net which i need to call from Flash As3...

i am using below code to do that. I have seen some post in which they say its working fine. But i am encountering below Error

Error: Error #2101: The String passed to URLVariables.decode() must be a URL-encoded query string containing name/value pairs.

Here is my code.

        var messages:Array = new Array ();           messages.push({"From":fromemailTxt.text,"To": ToemailTxt.text,"Body": BodyText.text,"Subject":SubjectText.text});          var JsonObj:String = JSON.encode(messages);         trace(JsonObj);          var variables:URLVariables=new URLVariables(JsonObj);            RequestURL= srvStringURL;          var JSONLoader:URLLoader = new URLLoader();         JSONLoader.dataFormat=URLLoaderDataFormat.TEXT;          JSONLoader.addEventListener(IOErrorEvent.IO_ERROR, GetBookmarkURLError, false, 0, true);         JSONLoader.addEventListener(Event.COMPLETE, parseBookmarkURLResult, false, 0, true);           var hdr:URLRequestHeader = new URLRequestHeader("Content-type", "application/json");          var request:URLRequest = new URLRequest(RequestURL);         request.requestHeaders.push(hdr);         request.data=variables;         request.method = URLRequestMethod.POST;          try          {             JSONLoader.load(request);         }         catch (error:ArgumentError)          {              trace("An ArgumentError has occurred."+error.errorID.toString());          }          catch (error:SecurityError)          {              trace("A SecurityError has occurred.");          }         catch (error:Error)          {             trace("Unable to load requested document.");         } 

Anybody have any idea on this?? Thanks

07/03/2012 06:39Top#2

Engineer

Member

Joined at: 12 months ago

Post: 34

Thank: 0

Thanked: 0

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

29/03/2016 09:33Top#3

Jalpa

Member

Joined at: 8 months ago

Post: 1

Thank: 0

Thanked: 0

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()); } 
Similar articles

Open a folder in finder/explorer from a webpage?

5 years ago - Reply: 2 - Views: 80

How do I escape a reserved word in Actionscript?

5 years ago - Reply: 2 - Views: 199

Save PPS/PPT files as SWF using C#

5 years ago - Reply: 2 - Views: 171

Ways of making a graphic/visual novel in flash

6 years ago - Reply: 3 - Views: 114

Use PhoneGap + HTML5 and an Embedded Flash Movie

5 years ago - Reply: 2 - Views: 96

View word docs and PDF in browser?

5 years ago - Reply: 2 - Views: 52

ActionScript 3 Read JPEG quality

7 years ago - Reply: 2 - Views: 59

Export/Test Movie Issues

5 years ago - Reply: 3 - Views: 39

Flash always on top in Android browser workaround?

5 years ago - Reply: 2 - Views: 149

Sending Json Form from Flash AS3

5 years ago - Reply: 2 - Views: 29

parsing a swf/fla (using php?)

6 years ago - Reply: 2 - Views: 44

Getting high FPS on Flash/AIR games for mobile?

5 years ago - Reply: 2 - Views: 59

vé máy bay vé máy bay giá rẻ ve may bay ve may bay gia re vé máy bay vé máy bay giá rẻ ve may bay ve may bay gia re vé máy bay vé máy bay giá rẻ ve may bay ve may bay gia re vé máy bay vé máy bay giá rẻ ve may bay ve may bay gia re vé máy bay vé máy bay giá rẻ ve may bay ve may bay gia re vé máy bay vé máy bay giá rẻ ve may bay ve may bay gia re vé máy bay vé máy bay giá rẻ ve may bay ve may bay gia re