When I executed this specific request in the browser, I got a HTTP 406 status code. The 406 status code says:
The resource identified by this request is only capable of generating responses with characteristics not acceptable according to the request "accept" headers ().Inspecting the request the browser sent, showed an accept-header of '*/*'. I compared this to the accept-header FireFox sent which was: 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8'.
The solution turned out to set the accept-header explicitly on the HttpService. I used the following code for this:
var httpService:HTTPService = new HTTPService();
httpService.url = url + "/tasks";
httpService.requestTimeout = 10;
// Set the content type expected by the server
httpService.contentType = "application/xml";
// Explicitly set the accept header
httpService.headers = { accept: "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8" };
httpService.resultFormat = "e4x";
As a sidenote, to disable HTTP caching on the server, you can use the following code:
response.addHeader("Pragma", "no-cache");
response.addHeader("Cache-Control", "no-cache");
response.addHeader("Cache-Control", "no-store");
response.addHeader("Cache-Control", "must-revalidate");
response.addHeader("Expires", "Mon, 8 Aug 2006 10:00:00 GMT");