private void SendNotification(ErrorNotification notification, bool useSSL)
{
string serializedJSON = notification.SerializeToString();
// Create a byte array:
byte[] byteArray = Encoding.UTF8.GetBytes(serializedJSON);
// Post JSON to server:
WebRequest request;
if(useSSL)
request = WebRequest.Create(httpsUrl);
else
request = WebRequest.Create(httpUrl);
request.Method = WebRequestMethods.Http.Post;
request.ContentType = "application/json";
request.ContentLength = byteArray.Length;
Stream dataStream = request.GetRequestStream();
dataStream.Write(byteArray, 0, byteArray.Length);
dataStream.Close();
// Get the response. See https://bugsnag.com/docs/notifier-api for response codes
var response = request.GetResponse();
}