/// <summary> /// Connect to pushbullet and make a send request /// </summary> private string PushBulletHttpRequest(string requestUrl, string accessToken, RequestType HttpRequestType, string pushBulletObject) { HttpsClient client = new HttpsClient(); client.PeerVerification = false; client.HostVerification = false; client.Verbose = false; HttpsClientRequest httpRequest = new HttpsClientRequest(); HttpsClientResponse response; try { httpRequest.KeepAlive = true; httpRequest.Url.Parse(requestUrl); httpRequest.RequestType = HttpRequestType; httpRequest.Header.SetHeaderValue("Content-Type", "application/json"); httpRequest.Header.SetHeaderValue("Access-Token", accessToken); httpRequest.ContentString = pushBulletObject; response = client.Dispatch(httpRequest); if (response.Code >= 200 && response.Code < 300) { // sucess return(response.ContentString); } else if (response.Code == 401 | response.Code == 403) { ErrorLog.Error("PushBullet Invalid Access Token"); OnDoorLockMessageReceived("PushBullet Invalid Access Token"); return("Error"); } else { // error responce ErrorLog.Error(response.ContentString.ToString()); return("Error"); } } catch (Exception e) { ErrorLog.Error("PushBulletHttpRequest Error: " + e.Message); return("Error"); } finally { client.Dispose(); } }