//POST APi private string PostWebApi(MSEBapiReq data) { string jsonMessage = string.Empty; string MSEBapiUrl = "http://wss.mahadiscom.in/wss/wss?uiActionName=postViewPayBill&IsAjax=true"; HttpClient client = new HttpClient(); var body = String.Format("BuNumber=" + data.BuNumber + "&ConsumerNo=" + data.ConsumerNo); StringContent theContent = new StringContent(body, System.Text.Encoding.UTF8, "application/x-www-form-urlencoded"); try { HttpResponseMessage aResponse = client.PostAsync(new Uri(MSEBapiUrl), theContent).Result; using (Stream responseStream = aResponse.Content.ReadAsStreamAsync().Result) { jsonMessage = new StreamReader(responseStream).ReadToEnd(); } } catch (Exception ex) { Logger.WriteLog(LogLevelL4N.ERROR, "Exception : " + ex.Message); } return(jsonMessage); }
public MSEBUserDetailsReqReturn GetMSEBUserStatus(MSEBUserDetailsReq mSEBUserDetailsReq) { MSEBUserDetailsReqReturn mSEBUserDetailsReqReturn = null; MSEBapiReq _msebapiReq = new MSEBapiReq { BuNumber = mSEBUserDetailsReq.BuCode, ConsumerNo = mSEBUserDetailsReq.ConsumerNo }; try { string json = this.PostWebApi(_msebapiReq); if (!json.Contains("error")) { mSEBUserDetailsReqReturn = JsonConvert.DeserializeObject <MSEBUserDetailsReqReturn>(json); } this._IsSuccess = true; } catch (Exception ex) { Logger.WriteLog(LogLevelL4N.ERROR, "GetMSEBUserStatus Exception : " + ex.Message); this._IsSuccess = false; } return(mSEBUserDetailsReqReturn); }