Wim Deblauwe
Wim Deblauwe

Reputation: 26848

Http POST from Adobe air not working

I have a Adobe Flex web application that we are converting to an Adobe AIR application. On the server side, I have a servlet that only accepts a HTTP POST request. We use navigateToUrl() to open a webpage with the result of that POST request. In the web application, this works perfectly (a new tab is opened with the result of the request), but it does not work from the Adobe AIR client, using the exact same code. The HTTP POST gets converted into a HTTP GET which is not accepted by the servlet. The web browser shows:

HTTP Status 405 - Request method 'GET' not supported.

This is how the request is made:

var request:URLRequest = new URLRequest();
request.method = URLRequestMethod.POST;
request.url = presentationModel.exportURL;

(The exportURL variable is a String which looks like http://ipaddress:8080/myapp/export/eventhistory1339595975131.html)

I checked this forum post but the solution given there (replacing a const that points to a String with the string itself) does not make sense, and did not work when I tried it.

I also looked at this question, but there is no real answer there. The comment indicates that the user added a trailing slash to his URL to make it work, but that does not work in my case, since the url is of the form: http://ipaddress:8080/myapp/export/eventhistory1339595975131.html

I am using Adobe Air 3.3 and Flex SDK 4.5

Upvotes: 1

Views: 1663

Answers (1)

James
James

Reputation: 979

Looking at the documentation for the navigateToURL method it appears to translate POST requests to GET

Parameters

request:URLRequest — A URLRequest object that specifies the URL to navigate to. For content running in Adobe AIR, when using the navigateToURL() function, the runtime treats a URLRequest that uses the POST method (one that has its method property set to URLRequestMethod.POST) as using the GET method.

Perhaps use a URLLoader instead?

Upvotes: 1

Related Questions