Copy link to clipboard
Copied
I am reading from, and sending to a web-service that uses JSON. Last night I wrote a little test code to get the authentication token from the service. If I publish to Flash Player 11.2 then it works fine. In Charles, the web debugger, I see the JSON object returned, and can parse it without issue in Flash.
Without _any_ code changes, I publish to AIR 3.2 for Desktop and I get a JSON error about not being able to parse key value pairs. In Charles I see that the returned object is now XML and not JSON. I'm going to need to ask the service provider wht might make the service return XML, but was wondering it anyone had seen this before, and if there's any kind of fix.
Copy link to clipboard
Copied
I got it worked out. Maybe I wouldn't call it a bug, but it's a definite difference in how FlashPlayer and AIR behave.
So, the fix was to add an Accept 'application./json' header to the request when using AIR. Flash player must do this automatically.
var hdr:URLRequestHeader = new URLRequestHeader("Accept", "application/json");
request.requestHeaders.push(hdr);
Find more inspiration, events, and resources on the new Adobe Community
Explore Now