Quantcast
Channel: Questions in topic: "webrequest"
Viewing all articles
Browse latest Browse all 387

UnityWebRequest read body response

$
0
0
Hy, I am trying to read the body response from a call to a server. The problem is that I get this error: NullReferenceException: Object reference not set to an instance of an object I can read the header when I do the UnityWebRequest call. The person gets added to the database on the server. I just can't get to the body of the respons. I need it so i can use the id in the app. Can sombedoy help me? this is my code: public void startButton() { StartCoroutine(CreateUser()); } IEnumerator CreateUser() { testclass myObject = new testclass(); myObject.email = "testmail@test.be"; myObject.password = "svhdshkhqfgv"; string jsonStringTrial = JsonUtility.ToJson(myObject); byte[] bodyRaw = new System.Text.UTF8Encoding().GetBytes(jsonStringTrial); var request = new UnityWebRequest("https://www.googleapis.com/identitytoolkit/v3/relyingparty/signupNewUser?key=serverapi", "POST"); request.uploadHandler = (UploadHandler)new UploadHandlerRaw(bodyRaw); yield return request.SendWebRequest(); if (request.isNetworkError || request.isHttpError) { Debug.Log(request.error); } else { Debug.Log("Form upload complete!"); Debug.Log(request.responseCode); Debug.Log("server response status: " + request.responseCode); Dictionary responseHeaders = request.GetResponseHeaders(); Debug.Log(responseHeaders.Keys); foreach (KeyValuePair entry in request.GetResponseHeaders()) { Debug.Log(entry.Value + "=" + entry.Key); } Debug.Log(request.downloadHandler.text); } }

Viewing all articles
Browse latest Browse all 387

Trending Articles



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