- Home /
Get data from REST works on Unity but not on Android Device
I'm working on a project where I get data from an url which provide a json string data. This works on Unity but it's not working on Android Device. Am I missing something?
Answer by Bunny83 · Dec 03, 2019 at 06:50 PM
Well you removed an important detail from your code which is your used URL scheme / protocol. The latest Android devices, by default, do no longer allow insecure HTTP connections and always require HTTPS. There are ways around that limitation but depending on what data you actually send / receive you might get in trouble with privacy and data security (also depends on your target countries).
Note that while using a self-signed SSL certificate could work, self-signed certificates are very often rejected by clients because they are vulnerable to man-in-the-middle attacks. If the server you want to connect to is owned by yourself you could use a Let's Encrypt certificate. Let's Encrypt certificates are usually accepted by most clients. Though if you want to be on the safe side you might want to get a proper (usually paid) certificate.
If you already use HTTPS and you are sure the certificate is configured and installed properly on your server, you should check your log when testing on your android device. Without more details we can't help you any further.
ps: I successfully use a Let's Encrypt certificate on my raspberry pi server which does re-new the certificate through a cron job every few month (since Let's Encrypt certificates have a validity of 3 months). I also have a free dyndns domain name which I created my certificate for.
Wow! Thanks for the reply.. $$anonymous$$y address was on HTTP, it wasn't configured properly yet. That explain why I can receive my data on my Editor where I don't see it on my device. Do you know how to make the device to accept data from unsecured site? It is for testing purpose only thanks.
Edit: Nvm, it was on your answer. Stupid me.
Your answer
Follow this Question
Related Questions
Why do I get Parse error (code 400) from Google Ftiness API in Unity? 0 Answers
HTTP PUT in Unity for iOS? 2 Answers
UnityWebRequest object downloadhandler.text not returning same/all data compared to browser 0 Answers
What is a good cross-platform alternative to WWW? 0 Answers
Unable to call external API (IBM Watson) via HTTP request? 1 Answer