Reputation: 3
I have to make a game for my thesis. I'm coding in ActionScript3. I have to use a service (REST interface). I've already read something about doing a GET.
How to access REST service in Actionscript 3?
Someone wrote that this code could be also use to do a POST, but how would the code change? How to do a POST from ActionScript3? Thank you in advance?
Upvotes: 0
Views: 876
Reputation: 1010
The key is the URLRequest, and the method
property. Leveraging from the example you referenced, modify the code to be
var req:URLRequest = new URLRequest("http://localhost:3000/api/user/id");
req.method = "POST"'
loader.load(req);
Upvotes: 0
Reputation: 1111
Basically you configure the URLRequest
differently:
var request = new URLRequest("http://localhost:3000/api/user/id");
request.method = URLRequestMethod.POST
loader.load(request);
see http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/net/URLRequest.html#method for more.
Upvotes: 0
Reputation: 8149
You just change the method of the URLRequest
object. By default, it uses GET.
var l:URLLoader = new URLLoader();
var req:URLRequest = new URLRequest( URL );
req.method = URLRequestMethod.POST; //this sets it to POST instead of GET
l.load( req );
See URLRequest.method
in the LiveDocs
Upvotes: 1