Quantcast
Channel: Questions in topic: "httpwebrequest"
Viewing all articles
Browse latest Browse all 190

UnityWebRequest object downloadhandler.text not returning same/all data compared to browser

$
0
0
WWWForm form = new WWWForm(); form.AddField("username", "admin"); form.AddField("password", "pass"); form.AddField(key1, value1); form.AddField(key2, value2); form.AddField(key3, value3); string realToken = ""; using (UnityWebRequest www = UnityWebRequest.Post(tokenURL, form)) { yield return www.SendWebRequest(); if (www.isNetworkError || www.isHttpError) { Debug.Log(www.error); } else { byte[] token = www.downloadHandler.data; string result1 = Encoding.Default.GetString(token); string result = System.Text.Encoding.UTF8.GetString(token); Debug.Log(www.downloadHandler.text); Debug.Log("result1 = " + result1); Debug.Log("result = " + result); } } Unity's output:

{"token":"HaFfPZi3GRhJJDbIdH6Oze2o0ToctdU7-nnzIhnWyZA.","expires":1528242946005}

result1 = {"token":"HaFfPZi3GRhJJDbIdH6Oze2o0ToctdU7-nnzIhnWyZA.","expires":1528242946005}

result = {"token":"HaFfPZi3GRhJJDbIdH6Oze2o0ToctdU7-nnzIhnWyZA.","expires":1528242946005}

what i want is the long "HaFfPZ....." string but it always ends with a '.' (which is never in the browser value) and cuts off the remaining data for that value. For example the same data in the browser would look something like

{"token":"HaFfPZi3GRhJJDbIdH6OzWy0JIOYDJ84ABYvu9pBcOQVnXPdltJhn0ILjBdpZp8Z","expires":1528243370083}

it seems the unity value there returns around 43 characters, and the browser value returns 64 characters.

any ideas?

thanks in advance

Viewing all articles
Browse latest Browse all 190

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>