Highlighted

how to call web api or service json using flash as3

Participant ,
May 24, 2017

Copy link to clipboard

Copied

Dear Friends,

Iam creating an app using Air for IOS, Initially iam doing login screen, when I enter username, and password it should communicate with server, check whether the user exist or not. Iam using web api or service and getting response as json. My other team mates gave me the web service its working fine in browser (tested with fiddler software) and giving result as 200. When iam using the same with AS3 its not working and giving error message as "error":"unsupported_grant_type".  Iam

public function checkServerLogin(aThis: MovieClip = null, aFun: String = null, aValues: String = null) {

    spath = "http://1.0.0.165/testproject/token"

   externalObj = aThis

   customEventName = aFun;   

   var urlVariable: URLVariables = new URLVariables();     

   var myRequest: URLRequest = new URLRequest(spath);

   myRequest.method = URLRequestMethod.POST;  

   var splitvalues= aValues.split("~");

   urlVariable.grant_type="password&username=testuser&password=Abcd1234!";

   myRequest.data = urlVariable;  

   loader.dataFormat = URLLoaderDataFormat.TEXT;

   loader.addEventListener(Event.COMPLETE, check_Server_Data);

   loader.addEventListener(HTTPStatusEvent.HTTP_RESPONSE_STATUS,httpResponceStatus)

   loader.addEventListener(IOErrorEvent.IO_ERROR, check_Server_Data_IOError);

   loader.load(myRequest);

  }

private function check_Server_Data(evt: Event) {

   trace("final result is : "+loader.data);

   loader.removeEventListener(Event.COMPLETE, check_Server_Data);

   loader.removeEventListener(IOErrorEvent.IO_ERROR, check_Server_Data_IOError);

   externalObj[customEventName](accessCode+"|"+loader.data) 

  }

Please help me to solve this issue. Thanks in advance....

Thanks and Regards,

Syed Abdul Rahim

TOPICS
Development

Views

631

Likes

Translate

Translate

Report

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

how to call web api or service json using flash as3

Participant ,
May 24, 2017

Copy link to clipboard

Copied

Dear Friends,

Iam creating an app using Air for IOS, Initially iam doing login screen, when I enter username, and password it should communicate with server, check whether the user exist or not. Iam using web api or service and getting response as json. My other team mates gave me the web service its working fine in browser (tested with fiddler software) and giving result as 200. When iam using the same with AS3 its not working and giving error message as "error":"unsupported_grant_type".  Iam

public function checkServerLogin(aThis: MovieClip = null, aFun: String = null, aValues: String = null) {

    spath = "http://1.0.0.165/testproject/token"

   externalObj = aThis

   customEventName = aFun;   

   var urlVariable: URLVariables = new URLVariables();     

   var myRequest: URLRequest = new URLRequest(spath);

   myRequest.method = URLRequestMethod.POST;  

   var splitvalues= aValues.split("~");

   urlVariable.grant_type="password&username=testuser&password=Abcd1234!";

   myRequest.data = urlVariable;  

   loader.dataFormat = URLLoaderDataFormat.TEXT;

   loader.addEventListener(Event.COMPLETE, check_Server_Data);

   loader.addEventListener(HTTPStatusEvent.HTTP_RESPONSE_STATUS,httpResponceStatus)

   loader.addEventListener(IOErrorEvent.IO_ERROR, check_Server_Data_IOError);

   loader.load(myRequest);

  }

private function check_Server_Data(evt: Event) {

   trace("final result is : "+loader.data);

   loader.removeEventListener(Event.COMPLETE, check_Server_Data);

   loader.removeEventListener(IOErrorEvent.IO_ERROR, check_Server_Data_IOError);

   externalObj[customEventName](accessCode+"|"+loader.data) 

  }

Please help me to solve this issue. Thanks in advance....

Thanks and Regards,

Syed Abdul Rahim

TOPICS
Development

Views

632

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
May 24, 2017 0
rewb0rn LATEST
Advocate ,
May 25, 2017

Copy link to clipboard

Copied

This has probably nothing to do with Action Script, but my guess is that your server is expecting the grant_type variable in a different format. Are you sure that you have to encode all your variables into it? Can you copy and paste the call from your browser test? Then we can compare whats wrong.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
May 25, 2017 0