Skip to main content
Inspiring
May 25, 2017
Question

how to call web api or service json using flash as3

  • May 25, 2017
  • 1 reply
  • 815 views

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

This topic has been closed for replies.

1 reply

natural_criticB837
Legend
May 25, 2017

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.