0

Im trying to send this JSON Get request to a server from my Unity App:

http://192.168.100.54/api/seohardw/%7b%22uuid%22%3a%22b2d31111c283ab159aa3f503fe53bebe952cfe9c%22%2c%22model%22%3a%22Dell+System+XPS+L502X+(Dell+Inc.)%22%2c%22name%22%3a%22LAPTOYIIICWIN%22%2c%22os%22%3a%22Windows+7++(6.1.0)+64bit%22%7d

Which decodes to this request:

http://192.168.100.54/api/seohardw/{"uuid":"b2d31111c283ab159aa3f503fe53bebe952cfe9c","model":"Dell+System+XPS+L502X+(Dell+Inc.)","name":"LAPTOYIIICWIN","os":"Windows+7++(6.1.0)+64bit"}

From my computer works perfectly pressing play button on unity, but when i compile the app and download it into my android cellphone it doesn't work

This is my web routine:

IEnumerator SendSeoHardw()
    {
        string url = ServerURL + "seohardw/";

        SeoFields SeoF = new SeoFields();
        SeoF.uuid = SystemInfo.deviceUniqueIdentifier;
        SeoF.model = SystemInfo.deviceModel;
        SeoF.name = SystemInfo.deviceName;
        SeoF.os = SystemInfo.operatingSystem;

        json = WWW.EscapeURL(JsonUtility.ToJson(SeoF));

        Debug.Log(url + json);

        WWW www = new WWW(url + json);
        yield return www;

        json = www.text;
        yield return null;
    }

Any ideas on what can be happening?

Regards...

---- EDIT: -----

I just saw mi server logs and the requests doesn't look so different:

192.168.100.17 - - [08/Jul/2018:16:10:08 -0500] "GET /api/seohardw/%7b%22uuid%22%3a%22b2d31111c283ab159aa3f503fe53bebe952cfe9c%22%2c%22model%22%3a%22Dell+System+XPS+L502X+(Dell+Inc.)%22%2c%22name%22%3a%22LAPTOYIIICWIN%22%2c%22os%22%3a%22Windows+7++(6.1.0)+64bit%22%7d HTTP/1.1" 200 185 "-" "UnityPlayer/2018.1.4f1 (UnityWebRequest/1.0, libcurl/7.51.0-DEV)"

192.168.100.100 - - [08/Jul/2018:16:12:24 -0500] "GET /api/seohardw/%7b%22uuid%22%3a%224e9ba43ae60db57d979031c588a4ad38%22%2c%22model%22%3a%22samsung+GT-I9505%22%2c%22name%22%3a%22%3cunknown%3e%22%2c%22os%22%3a%22Android+OS+7.1.2+%2f+API-25+(NJH47F%2f41b3993b48)%22%7d HTTP/1.1" 404 736 "-" "Dalvik/2.1.0 (Linux; U; Android 7.1.2; GT-I9505 Build/NJH47F)"

---- EDIT 2: -----

I changed my routine to use UWR and the result is the same, my new routine is this:

IEnumerator SendSeoHardw()
    {
        string url = ServerURL + "seohardw/";

        SeoFields SeoF = new SeoFields();
        SeoF.uuid = SystemInfo.deviceUniqueIdentifier;
        SeoF.model = SystemInfo.deviceModel;
        SeoF.name = SystemInfo.deviceName;
        SeoF.os = SystemInfo.operatingSystem;

        json = WWW.EscapeURL(JsonUtility.ToJson(SeoF));

        UnityWebRequest uwr = UnityWebRequest.Get(url + json);
        uwr.SetRequestHeader("Content-Type", "application/json; charset=utf-8");
        //Send the request then wait here until it returns
        yield return uwr.SendWebRequest();

        if (uwr.isNetworkError)
        {
            Debug.Log("Error While Sending: " + uwr.error);
        }
        else
        {
            Debug.Log("Received: " + uwr.downloadHandler.text);
        }
    }
Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
Chico3001
  • 1,853
  • 1
  • 22
  • 43
  • What does www.error say? – Fredrik Widerberg Jul 08 '18 at 21:04
  • 404 not found,if i do Application.OpenURL(url+json) it will open Android browser with the same error, if i remove the JSON payload the URL will open normally – Chico3001 Jul 08 '18 at 21:14
  • Not how to send json. To send json, set the `Content-Type` header. Also, I think you should be using `UnityWebRequest` as it simplifies stuff like this – Programmer Jul 09 '18 at 00:14
  • Is not a duplicate because I'm not asking how to send a JSON, I'm asking why the same routine that works perfectly on a PC fails on an Android, i changed the routine to use UWR and has exactly the same error – Chico3001 Jul 09 '18 at 01:05

0 Answers0