Here is my web request code block,
scroll down to the bottom of it to the catch exception
try
{
var webRequest = System.Net.WebRequest.Create (WEBSERVICE_URL);
if (webRequest != null) {
webRequest.Method = "POST";
//webRequest.Timeout = 12000;
webRequest.ContentType = "application/x-www-form-urlencoded";
webRequest.Headers.Add ("Key", _apiKey);
webRequest.Headers.Add ("Sign", genHMAC ());
byte[] dataStream = Encoding.UTF8.GetBytes("command=returnBalances&nonce=" + nonce);
webRequest.ContentLength = dataStream.Length;
Stream newStream = webRequest.GetRequestStream();
newStream.Write(dataStream, 0, dataStream.Length);
newStream.Close();
using (System.IO.Stream s = webRequest.GetResponse ().GetResponseStream ()) {
using (System.IO.StreamReader sr = new System.IO.StreamReader (s)) {
var jsonResponse = sr.ReadToEnd ();
OutputText.text = jsonResponse.ToString ();
}
}
}
}
catch (Exception ex)
{
OutputText.text = ex.ToString ();
}
This gives me an "error(403) Forbidden" and the exception stack trace, but I am trying to get the 403 Response Body:
I cannot get Unity C# to accept the following code: mentioned here
catch(WebException ex)
{
var response = (HttpWebResponse)ex.Response;
}
What do I need to make this method work? I need the Response body