network.request post query works in iOS and simulator, but not on android?

I’m writing a game that passes bonuses collected to a server.

The call to the server works fine in the simulator and iOS, yet fails on all android devices we’ve tested (my own test device is a SGII).

I’ve got to the stage where I am urlencoding the query and setting the network.request header type to “application/x-www-form-urlencoded”, although it should be noted that those additions changed nothing (IE it worked before either of these changes - we made sure the parameters and values never used iffy characters).

What on earth could the difference be? This is truly a game-ender - we don’t get this to work and we lose the client, as the posting is an integral part of the game (bonuses in-game translate to real-world bonuses).

Help!

Barry

Inludo

Hi Barry,

Just a few questions first; are you logging the user in before sending this post request? are you using https for the call? If you could give us some more information on what your doing that would be handy!

I’ve recently had some issues with Android and network.requests, but after some fiddling i got it working. Heres the headers i tend to use: 

    headers[“Content-Type”] = “application/x-www-form-urlencoded”

    headers[“Accept-Encoding”] = “”

    headers[“Accept-Language”] = “en”

    headers[“Cookie”] = storedCookie

As you can see i’ve blanked out Accept-Encoding just incase the Android device doesn’t support gzip. I’m honestly not sure if that helps at all, but i kept it anyway. The next thing you’ll notice is i also send the Cookie of the session with the header. I log the user in with Https calls and on Android the cookie wasn’t being stored and passed on in subsequent requests. Therefore i grab the cookie information from the event.responseHeaders array, store it and then use it for any other calls. If your not using https and not logging the user in then this may not help, but let me know :smiley:

Best of luck,

Jamie

Hi there, I’m not using https to log in, but the system does work with cookies. It did occur to me that the difference might be in the headers, as it is the only thing that could concievably change.

I already have the content-type as you put it, but the language and encoding I hadn’t put. As far as the cookie goes, it shouldn’t be needed (the server sends me a an authorise token upon login that is only valid for a set duration), however I will give this a try when I have time, as they needed a version that works ‘yesterday’ so I hacked in saving an encrypted and obfuscated password (obviously not ideal and I will strip it as soon as possible!).

Thanks for your info, I will test it as soon as possible and report back!

Barry

That sounds like a similar issue i had. The authorisation token may not be a cookie but you may still have to store it and send it back on Android. Put the app on your Android device and print all the response headers for your network call, then you can see if theres a cookie or an authorisation token you can use.

Essentially Android is a bit of a pain, hope it goes well.

Hi Barry,

Just a few questions first; are you logging the user in before sending this post request? are you using https for the call? If you could give us some more information on what your doing that would be handy!

I’ve recently had some issues with Android and network.requests, but after some fiddling i got it working. Heres the headers i tend to use: 

    headers[“Content-Type”] = “application/x-www-form-urlencoded”

    headers[“Accept-Encoding”] = “”

    headers[“Accept-Language”] = “en”

    headers[“Cookie”] = storedCookie

As you can see i’ve blanked out Accept-Encoding just incase the Android device doesn’t support gzip. I’m honestly not sure if that helps at all, but i kept it anyway. The next thing you’ll notice is i also send the Cookie of the session with the header. I log the user in with Https calls and on Android the cookie wasn’t being stored and passed on in subsequent requests. Therefore i grab the cookie information from the event.responseHeaders array, store it and then use it for any other calls. If your not using https and not logging the user in then this may not help, but let me know :smiley:

Best of luck,

Jamie

Hi there, I’m not using https to log in, but the system does work with cookies. It did occur to me that the difference might be in the headers, as it is the only thing that could concievably change.

I already have the content-type as you put it, but the language and encoding I hadn’t put. As far as the cookie goes, it shouldn’t be needed (the server sends me a an authorise token upon login that is only valid for a set duration), however I will give this a try when I have time, as they needed a version that works ‘yesterday’ so I hacked in saving an encrypted and obfuscated password (obviously not ideal and I will strip it as soon as possible!).

Thanks for your info, I will test it as soon as possible and report back!

Barry

That sounds like a similar issue i had. The authorisation token may not be a cookie but you may still have to store it and send it back on Android. Put the app on your Android device and print all the response headers for your network call, then you can see if theres a cookie or an authorisation token you can use.

Essentially Android is a bit of a pain, hope it goes well.