HttpClient client = new HttpClient();
var content = new FormUrlEncodedContent(new Dictionary<string, string>() {
{ "number", "09129457000" }
});
client.DefaultRequestHeaders.Referrer = new Uri("http://sim.mci.ir/first-step");
var resp = await client.PostAsync("http://sim.mci.ir/chk-number-availability", content);
var repsStr = await resp.Content.ReadAsStringAsync();
async Task<string> GetResponseString(string text)
{
var httpClient = new HttpClient();
var parameters = new Dictionary<string, string>();
parameters["text"] = text;
var response = await httpClient.PostAsync(BaseUri, new FormUrlEncodedContent(parameters));
var contents = await response.Content.ReadAsStringAsync();
return contents;
}
And your final function call:
Task<string> result = GetResponseString(text);
var finalResult = result.Result;
Or even better:
var finalResult = await GetResponseString(text);
//var httpClient = new HttpClient();
//string responseJson = httpClient.GetAsync(string.Format("", Phone, Message))
// .Result.Content.ReadAsStringAsync().Result;
var url = "";
var postData = new Dictionary<string, string>
{
{ "cdkey", "" },
{ "password", "" },
{"phone" ,""},
{"message" ,""}
};
var urlEncodedContent = new FormUrlEncodedContent(postData);
var httpClient = new HttpClient();
var result = httpClient.PostAsync(url, urlEncodedContent).Result.Content.ReadAsStringAsync().Result;