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

Try catch alternative for HTTP request

$
0
0
Hello, When connecting to a REST api, randomly and in some android devices I get errors when doing a POST. The errors are allways Curl error.... and they usually appear when the users are connected to free wifis and probably with wifis with extra security. The issue is that when the error appear, the coroutine crashes, and fails, It doesnt return a http or network error and I am being unable to control the crashes because I cant use try catch with a return statement inside. using (var request = new UnityWebRequest(string.Concat(server, url, applications, id, refreshToken), "POST")) { byte[] bodyRaw = Encoding.UTF8.GetBytes(form); request.uploadHandler = (UploadHandler)new UploadHandlerRaw(bodyRaw); request.downloadHandler = (DownloadHandler)new DownloadHandlerBuffer(); request.SetRequestHeader("Content-Type", "application/json"); request.SetRequestHeader("Authorization", "Bearer " + loginInfo.data.access_token); yield return request.SendWebRequest();

Viewing all articles
Browse latest Browse all 190

Trending Articles



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