public async Task <RVal> PostApiAsync() { var rval = new RVal(); HttpResponseMessage res = null; try { var req = new HttpRequestMessage(HttpMethod.Post, Url) { Content = new StringContent(RequestData, Encoding.UTF8, "application/json") }; var prescoAPI = new PRESCOAPI(); req.Headers.Add("Authorization", prescoAPI.PostToken()); var client = new HttpClient(); res = await client.SendAsync(req); rval = await GetResponseMsg(res); } catch (Exception ex) { } finally { } return(rval); }
public HttpWebRequest GenerateRequest() { var httpWebRequest = (HttpWebRequest)WebRequest.Create(Url); var prescoAPI = new PRESCOAPI(); if (!string.IsNullOrEmpty(ContentType)) { httpWebRequest.ContentType = ContentType; } httpWebRequest.Headers.Add("Authorization", prescoAPI.PostToken()); return(httpWebRequest); }