Hello, I have a code that downloads data from a url. I have a problem that one Url gives me error 403 (Forbidden) only from android. When i get the url from editor or Windows build, all works perfectly.
So if i could see the Request that WWW or UnityWebRequest does from android and Windows i would be able to compare whats going wrong.
I tested it with two codes ( WWW and UnityWebRequest) and both give the same result.
i tested it with other urls that contains xml, and it works.
Url: http://www.mambiente.madrid.es/opendata/horario.xml
WWW
IEnumerator DownloadXml(string url, DateTime data = new DateTime())
{
WWW www = new WWW(url);
yield return www;
ParseXML text = new ParseXML();
string file = www.text;
UnityWebRequest
IEnumerator GetRequest(string url, DateTime data, bool actualPolution)
{
using (UnityWebRequest webRequest = UnityWebRequest.Get(url))
{
// Request and wait for the desired page.
yield return webRequest.SendWebRequest();
if (webRequest.isNetworkError)
{
Debug.Log(url + ": Error: " + webRequest.error);
}
else
{
ParseXML text = new ParseXML();
string file = webRequest.downloadHandler.text;
Debug.Log(url + ":\nReceived: " + file);
↧