How do I…
How do I get a network request to my own server to work, even when exporting to APK?
I have distilled the simplest “GET” request in GDevelop, simplified from this simple example that queries the Star Wars server: Parse json from api - a game example from the GDevelop game making app | GDevelop
Pointed at my server:
Pointed at the Star Wars server:
As you can see, it’s the exact same code. The second two lines are literally the exact same, it’s just for context. The only difference is that the first line of code points to my server instead of the Star Wars server.
What is the expected result
The expected result is that the text object is populated by the JSON contents that has been requested, in this case the variable “id” which has the value “123”. This happens just fine when exported to Web or Linux. The text object shows up the contents of the JSON results “123”. The issue is that, when exported to APK, it does not exhibit the same behavior.
You can see the JSON works fine: https://tilde.camp/chat/secret
What is the actual result
For some reason, when the code is pointed at my server, and it’s exported to APK, then when you try to receive the “123” from the server it just shows up as “0”.
Stranger still, I can’t duplicate the error with the Star Wars server. The exact same line of code pointed at a different server actually works fine, even when exported to an APK.
The most obvious possibility is that something is wrong with my server, but then why would it work when exported to Web or Linux?