1 Reply Latest reply on May 8, 2013 2:02 AM by lesavage

    HTTPRequest

    andrewGP9

      First time I'm using the HTTPRequest class to communicate with a server....

       

      So I've imported the com.adobe.awsi library and making a simple GET request works fine.

       

      var request:HttpRequest = new HttpRequest(HttpRequest.GET, "http://myurl.here", "");

      request.perform(function(response:HttpResponse){

        trace(response);

      });

       

       

      But making a POST request is a bit more puzzling, since I don't see how I can send along the document body as part of the request.

       

           var request:HttpRequest = new HttpRequest(HttpRequest.POST, "http://myurl.here", "");

          var str:String = "Send this string as part of my POST request";    

          request.perform(function(response:HttpResponse){

        trace(response);

      });

       

      Any ideas where I add that str?

        • 1. Re: HTTPRequest
          lesavage Adobe Employee

          Hi andrewGP9,

           

          In CS Extension Builder we provide a CS Extension sample called 'Polyglot'. In CS Extension Builder choose File -> Import -> Adobe Creative Suite Extension Builder > Remote Creatove Suite SDK Examples

           

          Click Next and select 'Polyglot'.

           

          In the source code for Polyglot, open AppController and function useGoogleApis. Although the request is a GET, you will see the following syntax:

           

          request.setParam("v","1.0");

          request.setParam("q",text);

           

          This syntax can also be used for adding parameters to a POST request.

           

          For further information, please refer to the API documentation which is available in CS Extension Builder through Help > CS Extension Builder Start Page > Learn More > Docs and API Reference > Adobe Web Services Infrastructure Library API Reference

           

          I hope this helps,

          Lea