I have one service method which is using HttpWebRequest
for below stuff
- while (ub < sentCount)
- {
- ub = step * (1 + (i++));
-
- var k = (ub > sentCount) ? (sentCount) : ub;
-
- for (int j = lb; j < k; j++)
- {
- pnos = pnos + "," + pnosList[j].Phone;
- }
- pnos = pnos.Substring(1);
-
- var sbPostData = new StringBuilder();
- sbPostData.AppendFormat("authkey={0}", api.AuthenticationKey);
- sbPostData.AppendFormat("&mobiles={0}", pnos);
- sbPostData.AppendFormat("&message={0}", message);
- sbPostData.AppendFormat("&sender={0}", api.SenderId);
- sbPostData.AppendFormat("&route={0}", "default");
- string sendSMSUri = api.EndPoint;
-
-
-
- var httpWReq = (HttpWebRequest)WebRequest.Create(sendSMSUri);
-
- var encoding = new UTF8Encoding();
- byte[] data = encoding.GetBytes(sbPostData.ToString());
-
- httpWReq.Method = "POST";
- httpWReq.ContentType = "application/x-www-form-urlencoded";
-
- using (Stream stream = httpWReq.GetRequestStream())
- {
- stream.Write(data, 0, data.Length);
- }
-
- var response = (HttpWebResponse)httpWReq.GetResponse();
- var reader = new StreamReader(response.GetResponseStream());
- string responseString = reader.ReadToEnd();
-
-
- reader.Close();
- response.Close();
-
- lb = ub;
- pnos = string.Empty;
- }
Now the same thing I need to do in HttpClient
is it possible to do that. Issue I am facing is HttpWebRequest
is not supporting in PCL(C# class library) I want to move above logic to PCL.