问题
I'm working with a Jetty based REST service wrote by a 3rd party developer to which I have to make calls from actionscript 3. There are multiple calls available and most of them work, there only one I'm having trouble with: To end a session I have to make a POST request to http://localhost/control/end.
I've made a basic test with Simple Rest Client in Chrome and that works:
- I get a status 200 response
- In service's console I see a
setEndcall made
The problem is, when I try the same in actionscript, it doesn't seem to work. Here's my basic call:
private function deleteSID(event : MouseEvent) : void {
var request:URLRequest = new URLRequest(SERVER+"control/end");
request.method = URLRequestMethod.POST;
var loader:URLLoader = new URLLoader();
loader.addEventListener(Event.COMPLETE, deletedSID);
loader.addEventListener(IOErrorEvent.IO_ERROR, onIOError);
loader.addEventListener(HTTPStatusEvent.HTTP_STATUS , onHTTPStatus);
loader.load(request);
}
But I get a 404 instead of a 200, as if it's not actually doing a POST.
Unfortunately I don't have a lot experience with REST APIs, so any hint/tip on what I might be missing is appreciated.
回答1:
Try sending some data with your POST call:
var requestVars:URLVariables = new URLVariables();
requestVars.dummy = "lol";
...
request.data = requestVars;
来源:https://stackoverflow.com/questions/10262149/issue-with-making-a-post-call-to-a-rest-service-from-as3