public async Task ProcessFile(HttpSessionStateBase currentsession, string CredId) { string accessToken = UserSession.accessToken(currentsession); HttpGetObject objHttpObject = new HttpGetObject(); objHttpObject.accessToken = accessToken; objHttpObject.endPoint = postProcessFileEndPoint; objHttpObject.id = CredId; APIClient apiclient = new APIClient(); ResultsFilePost objResultsFilePost = new ResultsFilePost(); objResultsFilePost.includeAllFiles = true; HttpResponseMessage dsResp = await apiclient.postAsync(objHttpObject, apiclient.convertToContent(objResultsFilePost)); if (!dsResp.IsSuccessStatusCode) { errorOccurred = true; } string val = await dsResp.Content.ReadAsStringAsync(); objGenericResp = new GenericResp(); objGenericResp = JsonConvert.DeserializeObject <GenericResp>(val); }
public async Task <bool> AttempLogin(HttpSessionStateBase currentSession) { bool isSuccess = true; LogIn userlogin = new LogIn() { emailAddress = this.emailAddress, passWord = this.passWord }; HttpGetObject httpreq = new HttpGetObject(); httpreq.endPoint = loginEndPoint; APIClient api = new APIClient(); HttpResponseMessage resp = await api.postAsync(httpreq, api.convertToContent(userlogin)); if (!resp.IsSuccessStatusCode) { isSuccess = false; return(isSuccess); } string val = await resp.Content.ReadAsStringAsync(); APIKeyResp apikey = JsonConvert.DeserializeObject <APIKeyResp>(val); //use API Key to request token httpreq.endPoint = tokenEndPoint; resp = await api.postAsync(httpreq, api.convertToContent(apikey)); if (!resp.IsSuccessStatusCode) { isSuccess = false; return(isSuccess); } val = await resp.Content.ReadAsStringAsync(); TokenResp token = JsonConvert.DeserializeObject <TokenResp>(val); httpreq.accessToken = token.token; httpreq.endPoint = userProfileEndPoint; //httpreq. resp = await api.getAsync(httpreq); if (!resp.IsSuccessStatusCode) { isSuccess = false; return(isSuccess); } val = await resp.Content.ReadAsStringAsync(); GenericResp genId = JsonConvert.DeserializeObject <GenericResp>(val); UserSession.SetLoginValues(currentSession, apikey.apiKey, token.token, Convert.ToInt32(genId.id)); return(isSuccess); }