7 Replies Latest reply on Nov 12, 2012 11:20 AM by anixan

    Flex uses %5F as Underscore for HTTP Service?

    anixan

      I am currently developing a Mobile Application with Adobe Flex 4.6 and I am having an Issue with using the HTTP Service functionality. I am trying to use a HTTP request like shown below:

       

       

      http://api.somesite.co.uk/api/v1/data?api_key=00000aaaaa111111&area=London

       

       

      I have imported the service using the data menu and testing it using the parameters need and when i run a test on the service it pulls back the data fine and shows it in the "Test Operation" view.

       

       

      However when I then Add the following code to my view to test the application it returns a 2032 error:

       

       

          <?xml version="1.0" encoding="utf-8"?>
          <s:View xmlns:fx="http://ns.adobe.com/mxml/2009"
                              xmlns:s="library://ns.adobe.com/flex/spark"
                              xmlns:myservice="services.myservice.*"
                              initialize="view1_initializeHandler(event)" title="list">
                    <fx:Script>
                              <![CDATA[
                                        import mx.events.FlexEvent;
                                        import mx.rpc.events.FaultEvent;
                                        import mx.rpc.events.ResultEvent;
      
                                        import spark.events.IndexChangeEvent;
      
                                        protected function view1_initializeHandler(event:FlexEvent):void
                                        {
                                                  // TODO Auto-generated method stub
                                                  var api_key:String = "00000aaaaa111111"
                                                  var area:String = "London";
      
                                                  listResult.addEventListener(ResultEvent.RESULT, onResult);
                                                  listResult.addEventListener(FaultEvent.FAULT, httpFault);
                                                  listResult.token = service.list(api_key, area);
      
                                                  trace(listResult.token);
                                        }
      
                                        public function httpFault(event:FaultEvent):void { 
                                                  var faultstring:String = event.fault.faultDetail; 
                                                  trace("The Fault is: " + faultstring); 
                                        } 
      
                                        protected function onResult (event:ResultEvent):void
                                        {
      
                                        }
      
                                        protected function list_changeHandler(event:IndexChangeEvent):void
                                        {
      
                                        }
      
                                        protected function list_creationCompleteHandler(event:FlexEvent):void
                                        {
      
                                        }
      
                              ]]>
                    </fx:Script>
                    <fx:Declarations>
                              <s:CallResponder id="listResult" result="data=listResult.lastResult"/>
                              <myservice:MyService id="service"/>
                              <!-- Place non-visual elements (e.g., services, value objects) here -->
                    </fx:Declarations>
      
                    <s:List id="list" left="0" right="0" top="0" bottom="85" fontSize="20" contentBackgroundColor="#272727"
                                        creationComplete="list_creationCompleteHandler(event)" change="list_changeHandler(event)">
                              <s:AsyncListView list="{data}"/>
                              <s:itemRenderer>
                                        <fx:Component>
                                                  <s:IconItemRenderer
                                                            labelFunction="Name"
                                                            iconFunction="getImageURL"
                                                            iconHeight="80"
                                                            iconWidth="80">
                                                            <fx:Script>
                                                                      <![CDATA[
                                                                                import valueObjects.Item;
      
                                                                                private function Name(item: Object):String
                                                                                {
                                                                                          var item:Item = Item(item);
                                                                                          return listing.name;
                                                                                }
      
                                                                                private function getImageURL(item: Object):String
                                                                                {
                                                                                          var item:Item = Item(item);
                                                                                          return listing.image_url;
                                                                                }
      
                                                                      ]]>
                                                            </fx:Script>
                                                  </s:IconItemRenderer>
                                        </fx:Component>
                              </s:itemRenderer>
                    </s:List>
      
          </s:View>
      

       

      With the code above I have managed to track the issue to the fact that for some unknown stupid reason when the code is run from the view the url that is sent is wrong and the underscores are replaced by %5F as shown below:

       

       

      http://api.somesite.co.uk/api/v1/data?area=London&api%5Fkey=00000aaaaa111111

       

       

      Can anyone help me get around this issue?

       

       

      Thanks